[英]Getting this category.php to display a certain category! (Wordpress)
我试图获取一个页面来显示某个类别。 此特定页面是“思想和想法”
我想写一些关于我的想法和想法的行,并在其下显示ID为16的类别“ Thoughts”
我该怎么办?
这是我的主题category.php:
<?php get_header(); ?>
<div id="wrap">
<!-- Main Content-->
<img src="<?php bloginfo('template_directory');?>/images/content-top.gif" alt="content top" class="content-wrap" />
<div id="content">
<!-- Start Main Window -->
<div id="main">
<?php global $query_string; $catnum_posts = get_option('theme_catnum_posts') ;
query_posts($query_string . "&showposts=$catnum_posts&paged=$paged&cat=$cat"); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php include(TEMPLATEPATH . '/includes/entry.php'); ?>
<?php endwhile; ?>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { ?>
<?php include(TEMPLATEPATH . '/includes/navigation.php'); ?>
<?php } ?>
<?php else : ?>
<?php include(TEMPLATEPATH . '/includes/no-results.php'); ?>
<?php endif; wp_reset_query(); ?>
</div>
<!-- End Main -->
<?php get_sidebar(); ?>
我试图改变:
query_posts($query_string . "&showposts=$catnum_posts&paged=$paged&cat=$cat"); ?>
至
query_posts($query_string . "&showposts=$catnum_posts&paged=$paged&cat=16"); ?>
但是它没有用..
有任何想法吗?
类别页面上的全局$query_string
几乎可以肯定已经定义了cat
参数,这可能就是为什么它忽略了cat=16
。 通过遵循Kai的建议并调用wp_reset_query
我还将进行一个新的query_posts
。 试试这个循环:
<?php $catnum_posts = get_option('theme_catnum_posts') ;
wp_reset_query();
$cat = 16;
query_posts("&showposts=$catnum_posts&paged=$paged&cat=$cat"); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php include(TEMPLATEPATH . '/includes/entry.php'); ?>
<?php endwhile; ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.