admin管理员组文章数量:1404927
How can I get the first post THIS SAME CATEGORY? It's just that now he takes the very first post that is generally in this type, but it is necessary that he takes the first post in the same category as the last
if( get_adjacent_post(true, '', true) ) {
previous_post_link('%link', '<div class="navigation-portfolio-block"><h6 class="arrow-left mobile_navigation">Previous</h6></div> ');
} else {
$first = new WP_Query('post_type=portfolio&posts_per_page=1&order=DESC'); $first->the_post();
echo '<a href="' . get_permalink() . '">
How can I get the first post THIS SAME CATEGORY? It's just that now he takes the very first post that is generally in this type, but it is necessary that he takes the first post in the same category as the last
if( get_adjacent_post(true, '', true) ) {
previous_post_link('%link', '<div class="navigation-portfolio-block"><h6 class="arrow-left mobile_navigation">Previous</h6></div> ');
} else {
$first = new WP_Query('post_type=portfolio&posts_per_page=1&order=DESC'); $first->the_post();
echo '<a href="' . get_permalink() . '">
Share
Improve this question
asked Dec 23, 2019 at 13:46
KaizerKaizer
1
1 Answer
Reset to default 0You can use additional WP_Query parameters like post_per_page
For example,
$my_custom_query_args =
array( 'posts_per_page' =>1,
'orderby'=>'DESC');
$my_custom_query = new WP_Query( $my_custom_query_args );
本文标签: navigationHow can I get the first post THIS SAME CATEGORY
版权声明:本文标题:navigation - How can I get the first post THIS SAME CATEGORY? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744878361a2630053.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论