php WordPress循环| Conditonal

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WordPress循环| Conditonal相关的知识,希望对你有一定的参考价值。

@php $latestNews = new WP_Query( array(
  'post_type'       =>  'post',
  'order'           =>  'ASC',
  'orderby'         =>  'date',
  'posts_per_page'  => '2'
)); 
@endphp
 
@if( $latestNews->have_posts() )
<div id="news" class="news-section">
  <div class="container">
    <div class="row">
      @while ( $latestNews->have_posts() ) @php $latestNews->the_post() @endphp
        @include('partials.content-'.get_post_type())
      @endwhile @php wp_reset_postdata(); @endphp
    </div>
  </div>
</div>
@endif
<?php $latestNews = new WP_Query( array(
  'post_type'       =>  'post',
  'order'           =>  'ASC',
  'orderby'         =>  'date',
  'posts_per_page'  => '2'
)); ?>

<?php if( $latestNews->have_posts() ) : ?>
<section class="latest-news">
    <h2>latest news</h2>
    <?php while( $latestNews->have_posts() ) : $latestNews->the_post(); ?>
    
    // loop content
    
    <?php endwhile; wp_reset_postdata(); ?>
    
</section>
<?php endif; ?>

以上是关于php WordPress循环| Conditonal的主要内容,如果未能解决你的问题,请参考以下文章

php 循环WordPress

php WordPress - 自定义帖子类型循环

php wordpress:发布循环列表

php Wordpress循环结构(wp)

php WordPress - 自定义帖子类型循环

php wordpress从主循环中排除类别