繁体   English   中英

wordpress从一个类别获取帖子

[英]wordpress get posts from a category

嗨,我正在尝试建立我的第一个wordpress网站。 我一直试图从两个不同的类别中带出蝙蝠帖子,并将它们显示在同一页面上。 我将其带回去,但它始终将它们随机排列。 我想要一个来自一个类别的帖子,下面是一个来自另一类别的帖子。

到目前为止我所得到的

<?php get_head(); ?>

<div id="container">
<?php get_header(); ?>
<?php get_banner(); ?>

    <div class=" center content" role="main">
      <div id="posts">


          <div class="news">
                <?php query_posts('catname=news&showposts=3'); while (have_posts()) : the_post(); the_title(); the_content(); 
                endwhile;?>

                <div class="clear"></div>
          </div>
             <div class="msghead">
            <?php query_posts('catname=msghead&showposts=1'); while (have_posts()) : the_post(); the_title(); the_content(); 
            endwhile;?>

           </div>
        </div>
    </div>

    <div class="sidebardiv">
       <?php get_sidebar(); ?>
    <div class="clear">
    </div>
</div>
</div>
<?php get_footer(); ?>

</div>

您是否尝试过order和orderby查询参数?

http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

您的代码可能像这样,按日期顺序降序排列:

<?php query_posts('cat=news&showposts=3&orderby=date'); while (have_posts()) : the_post(); the_title(); the_content(); 
endwhile;?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM