最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

navigation - How can I get the first post THIS SAME CATEGORY?

programmeradmin5浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 0

You 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 ); 
发布评论

评论列表(0)

  1. 暂无评论