0

こんにちは、最初のワードプレス Web サイトを作成しようとしています。2 つの異なるカテゴリからコウモリの投稿を取り込み、同じページに表示しようとしています。投稿を元に戻しますが、ランダムな順序で配置し続けます。あるカテゴリからの投稿があり、別のカテゴリからの投稿が下にあることを望んでいます。

これが私がこれまでに得たものです

<?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>
4

1 に答える 1

1

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;?>
于 2012-11-11T15:35:49.813 に答える