admin管理员组文章数量:1435859
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
1 Answer
Reset to default 1Try 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,
),
),
));
本文标签: phpAdd to previous posts under post
版权声明:本文标题:php - Add to previous posts under post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745671592a2669601.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论