Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

wordpress - WordPress自定义查询仅显示两个帖子(Wordpress Custom Query shows only two post)

My custom query shows only 2 post, My post_ids in the array are correct and I've changed the number of $posts_per_page several times but still no luck.

(我的自定义查询仅显示2个帖子,数组中的post_ids是正确的,并且我多次更改了$ posts_per_page的数量,但还是没有运气。)

Any Suggestion will be helpful.

(任何建议都会有所帮助。)

Thanks in advance.

(提前致谢。)

<?php

    $paged                  = get_query_var("paged") ? get_query_var("paged") : 1;
    $posts_per_page         =  5;
    $post_ids               = array( 156, 151, 154, 157, 1, 15);
    $custom_q               = new WP_Query (array(
                                    'post__in'      => $post_ids,
                                    'orderby'       => 'post__in',
                                    'paged'         => $paged
                                ));
    while($custom_q->have_posts()){
        $custom_q->the_post();
        ?>
        <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
        <?php
    }
    wp_reset_query();

?>
  ask by Ami Hasan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...