我使用以下代碼來顯示發生後的信息。但我有一個問題。 我不想在博客頁面和主頁等特定頁面上顯示發佈信息。條件不工作在wordpress
所以我嘗試了一些方法,但不工作。
其實我剛纔創建的頁面模板.. 頁面blog.php的和頁面home.php
remove_action('genesis_before_post_content', 'genesis_post_info');
add_action('genesis_before_post_title', 'child_post_info');
function child_post_info() {
if (!is_page('blog')) {
return;
?>
<div class="post-info">
<span class="date published time">
<time class="entry-date" itemprop="startDate" datetime="<?php echo get_the_date('c'); ?>" pubdate><?php echo get_the_date(); ?></time>
</span> By
<span class="author vcard">
<a class="fn n" href="<?php echo get_the_author_url(get_the_author_meta('ID')); ?>" title="View <?php echo get_the_author(); ?>'s Profile" rel="author me"><?php the_author_meta('display_name'); ?></a>
</span>
<span class="post-comments">· <a href="<?php the_permalink() ?>#comments"><?php comments_number('Leave a Comment', '1 Comment', '% Comments'); ?></a></span>
<?php // if the post has been modified, display the modified date
$published = get_the_date('F j, Y');
$modified = the_modified_date('F j, Y', '', '', FALSE);
$published_compare = get_the_date('Y-m-d');
$modified_compare = the_modified_date('Y-m-d', '', '', FALSE);
if ($published_compare < $modified_compare) {
echo '<span class="updated"><em>· (Updated: ' . $modified . ')</em></span>';
} ?>
</div>
<?php }
}
,請給我一些想法我怎麼能解決這個問題。
NOW:
我創建了一個新的文件元postinfo.php
並保存
<div class="post-info">
...
</div>
和functions.php文件..
remove_action('genesis_before_post_content', 'genesis_post_info');
add_action('genesis_before_post_title', 'child_post_info');
function child_post_info() {
if (!is_home() && !is_page(array('blog', 'inspiring quotes'))) {
get_template_part('meta', 'postinfo');
};
}
上面的代碼正在與博客頁面和主頁,但不能與「鼓舞人心的報價頁面雖然我已經嘗試
if (!is_home() && !is_page('blog') && !is_page('inspiring quotes')) {
,但沒有工作..做u有什麼想法?
嘗試'鼓舞人心的報價' – 2012-08-03 04:10:24