php - Add to previous posts under post

Goal: After each post (that contains under a certain amount of words), display the two posts that were published before

Goal: After each post (that contains under a certain amount of words), display the two posts that were published before it in that category/tab.

I found this on stack, where they do something similar, but they're displaying the 2 most recent posts. I want to display the 2 that were published before the currently-read article, though. Is there a way to modify this code?

Goal: After each post (that contains under a certain amount of words), display the two posts that were published before it in that category/tab.

I found this on stack, where they do something similar, but they're displaying the 2 most recent posts. I want to display the 2 that were published before the currently-read article, though. Is there a way to modify this code?

Share Improve this question edited Mar 20, 2019 at 18:26 Qaisar Feroz 2,1471 gold badge9 silver badges20 bronze badges asked Mar 20, 2019 at 14:54 MantaRayMantaRay 254 bronze badges 1
  • WP_Query Date Parameters – Max Yudin Commented Mar 20, 2019 at 15:04
Add a comment  | 

1 Answer 1

Reset to default 1

Try to add date_query to the $qry in the solution mentioned here.

$qry = new WP_Query(
       array(
            'cat'            => $current_post_categories[0],
            'posts_per_page' => 2,
            'post__not_in'   => array( $current_post_id ),

            'date_query' => array(
                                 array(
                                     'before'     => $post->post_date,
                                 ),
                            ),

              ));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745671592a4639436.html

相关推荐

  • php - Add to previous posts under post

    Goal: After each post (that contains under a certain amount of words), display the two posts that were published before

    7小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信