wordpress 自定义查询 – WP_Query

本文由清尘发表于2019-01-03 22:30最后修改于2019-04-03属于WordPress分类
<?php get_header(); ?>
<div id="main-comtent">
  <div class="container">
    <?php $myqueryargs = array(
      'post_type'       => 'post',
      'posts_per_page'  =>  15,
      'orderby'         => 'date',
      'order'           =>  'ASC',
      'category__in'    =>  array(8,15)
    );?>
    <?php $myquery = new WP_Query($myqueryargs); ?>
    <?php if($myquery -> have_posts()): ?>
    <ol>
      <?php while($myquery -> have_posts()) : $myquery -> the_post(); ?>
      <li><?php the_title(); ?></li>
      <?php endwhile ?>
    </ol>
    <?php endif;?>
    <?php wp_reset_postdata(); ?>
  </div>
</div>
<?php get_sidebar('right'); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>