dongtangu6889 2017-10-12 18:30
浏览 56

获取WordPress上特定SUBCATEGORY的所有帖子?

Hey guys I am trying to get all post of a specific SUBCATEGORY (No category)

I'm using the subcategory ID ($option_id) on my code like this:

$option_id = get_cat_ID($option);

$query_args = array(
    'post_type' => 'post',
    'cat' => $option_id,
    // 'category_name' => $option,
    // 'category_in' => $option_id,
    'posts_per_page' => 8,
    'paged' => $paged
  );

$the_query = new WP_Query( $query_args );

while( $the_query->have_posts() ):
    $the_query->the_post();

    // Article code here...

endwhile;
wp_reset_query();

This is not working with the subcategories, but is working on categories.
Note: I have tried using category_name and category_in, I have the same result.

  • 写回答

1条回答 默认 最新

  • doupai5450 2017-10-12 20:41
    关注

    @FluffyKitten Hey again, the issues is my pagination ($paged)

    If I remove 'paged' => $paged I can see articles by subcategory pretty fine.

    I need to check my ajax pagination again; thank you very much for the support.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题