在我的存档页面中,我希望某个类别不显示。我正在添加的其余代码,但会转到自定义页面
逻辑是,如果是category=33
, 然后包括照片。php
<div class="latest_from_category">
<h2 class="latest_frm_cat_title archive_title"><?php if (have_posts()) : ?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */
if (is_category()) {
?>
<?php
_e(\'\', \'bilanti\'); ?>
\'<?php echo single_cat_title(); ?>\'
<?php _e(\'Archive For\', \'bilanti\'); ?>
<?php /* If this is a tag archive */
} elseif( is_tag() ) { ?>
<?php _e(\'Archive for the\', \'bilanti\'); ?>
<?php single_tag_title(); ?> Tag
<?php /* If this is a daily archive */
} elseif (is_day()) { ?>
<?php _e(\'Archive for\', \'bilanti\'); ?>
<?php the_time(\'F jS, Y\'); ?>
<?php /* If this is a monthly archive */
} elseif (is_month()) { ?>
<?php _e(\'Archive for\', \'bilanti\'); ?>
<?php the_time(\'F, Y\'); ?>
<?php /* If this is a yearly archive */
} elseif (is_year()) { ?>
<?php _e(\'Archive for\', \'bilanti\'); ?>
<?php the_time(\'Y\'); ?>
<?php /* If this is a search */
} elseif (is_search()) { ?>
<?php _e(\'Search Results\', \'bilanti\'); ?>
<?php /* If this is an author archive */
} elseif (is_author()) { ?>
<?php _e(\'Author Archive\', \'bilanti\'); ?>
<?php /* If this is a paged archive */
} elseif (isset($_GET[\'paged\']) && !empty($_GET[\'paged\'])) { ?>
<?php _e(\'Blog Archives\', \'bilanti\'); ?>
<?php } ?></h2>
<?php get_template_part( \'post-excerpt\' ); // Post Excerpt (post-excerpt.php) ?>
<?php else : ?>
<h3 class="archive_not_found">404 <span>not found</span></h3>
<?php endif; ?>
</div>
确切的代码应该是什么?
最合适的回答,由SO网友:Brad Dalton 整理而成
你可以使用template_include
有条件地
add_filter( \'template_include\', \'wpsites_photo_page_template\', 99 );
function wpsites_photo_page_template( $template ) {
if ( is_category(\'33\') ) {
$new_template = locate_template( array( \'photo.php\' ) );
if ( \'\' != $new_template ) {
return $new_template ;
}
}
return $template;
}