【问题标题】:Wordpress category filter with pagination带分页的 Wordpress 类别过滤器
【发布时间】:2015-04-17 01:59:22
【问题描述】:

是否有任何解决方案可以通过分页来按帖子类别进行过滤。目前,它只过滤当前页面中的帖子,但不再过滤。你可以在这里看到:The Method Case

谢谢!

【问题讨论】:

    标签: php wordpress filter categories


    【解决方案1】:

    您可以为此目的使用WP_Query。例如:

    <?php
    
    $posts = WP_Query(array(
      'category_name' => 'my-category',
      'paged' => 2 // Page 2
    ));
    
    while($posts->have_posts()): $posts->the_post();
      // do some stuff
    endwhile;
    
    ?>
    

    【讨论】:

      猜你喜欢
      • 2019-08-11
      • 2015-02-25
      • 2022-01-03
      • 1970-01-01
      • 2015-11-27
      • 1970-01-01
      • 1970-01-01
      • 2018-06-02
      • 2018-07-10
      相关资源
      最近更新 更多