从类别存档中排除子类别
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从类别存档中排除子类别相关的知识,希望对你有一定的参考价值。
Completely changed original function, which stopped working around WP2.8.
<?php // just before loop in category theme file: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $current_cat = get_query_var('cat'); 'paged' => $paged ); query_posts($args); // after loop in category theme file $cat = get_query_var('category__in'); set_query_var("cat",$cat[0]); // or in Thesis custom_functions.php function remove_child_cats() { if (is_category()) : $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $current_cat = get_query_var('cat'); 'paged' => $paged ); query_posts($args); remove_action('thesis_hook_archive_info', 'thesis_default_archive_info'); echo ' <div id="archive_info">' . " "; ?> <p><?php _e('From the category archives:', 'thesis'); ?></p> <h1><?php echo get_cat_name($current_cat); ?></h1> <?php echo ' </div>' . " "; endif; } add_action('thesis_hook_before_content','remove_child_cats'); function reset_cat() { $cat = get_query_var('category__in'); set_query_var("cat",$cat[0]); } add_action('thesis_hook_after_content','reset_cat');
以上是关于从类别存档中排除子类别的主要内容,如果未能解决你的问题,请参考以下文章