在页面上显示特定类别的帖子,主题为儿童主题?

时间:2012-08-12 作者:Rasha Nour Eldin

我有一个博客页面模板,我需要让它显示来自称为新闻的特定类别的帖子这是模板,我使用主题框架子主题

<?php
/**
* Template Name: Blog
*
* This template allows you to display the latest posts on any page of the site.
*
*/

    // calling the header.php
    get_header();

    // action hook for placing content above #container
    thematic_abovecontainer();

?>

<div id="container">
<?php thematic_abovecontent(); ?>
<div id="content">
<?php
$wp_query = new WP_Query();
$wp_query->query( array( \'posts_per_page\' => get_option( \'posts_per_page\' ), \'paged\' => $paged ) );
$more = 0;
?>

<?php

             // create the navigation above the content
             thematic_navigation_above();

             // calling the widget area \'index-top\'
             get_sidebar(\'index-top\');

             // action hook for placing content above the index loop
             thematic_above_indexloop();

             // action hook creating the index loop
             thematic_indexloop();

             // action hook for placing content below the index loop
             thematic_below_indexloop();

             // calling the widget area \'index-bottom\'
             get_sidebar(\'index-bottom\');

             // create the navigation below the content
             thematic_navigation_below();

             ?>
</div><!-- #content -->
<?php thematic_belowcontent(); ?>
</div><!-- #container -->

<?php

    // action hook for placing content below #container
    thematic_belowcontainer();

    // calling the standard sidebar
    /*thematic_sidebar();*/

    // calling footer.php
    get_footer();

?>

1 个回复
最合适的回答,由SO网友:chifliiiii 整理而成

尝试更改:

$wp_query->query( array( \'posts_per_page\' => get_option( \'posts_per_page\' ), \'paged\' => $paged ) );

$wp_query->query( array( \'category_name\' => \'news\',\'posts_per_page\' => get_option( \'posts_per_page\' ), \'paged\' => $paged ) );
您需要使用slug,在本例中,“news”是该类别的slug。

结束

相关推荐

NEXT_POST_LINK()中的EXCLUDE_CATEGORIES参数行为异常

我有一个Wordpress模板。php页面。该页面有“下一页”和“上一页”箭头,允许浏览所有帖子。我想将某些类别的帖子排除在“下一个”和“上一个”计算中。我有以下代码: // in single.php next_post_link( \'%link\', \'&larr; Previous\', false, \'11 and 13 and 15\'); 这应该会显示到下一篇文章的链接。第11、13和15类的职位不应按照the $ignore_categories para