Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #736541

    Hiya

    I’d like to sort posts in ascending order and have found this article, however i’d only like this to happen on one category. Is that possible?

    thanks
    Richard

    #738047

    Hey raslade,

    Try using is_category: https://developer.wordpress.org/reference/functions/is_category/

    The code should look something like:

    add_filter('avia_blog_post_query', 'avia_modify_post_grid_query_desc');
    
    function avia_modify_post_grid_query_desc( $query ) {
      if( is_category( 'blue-cheese' ) ) {
        $query['orderby'] = 'title';
        $query['order'] = 'DESC';
        return $query;
      }
    }

    Just change the value inside is_category. Let us know if this helps.

    Best regards,
    Nikko

    #739086

    Hi Nikko

    That’s fantastic thank you and works fine.

    Thanks for your help
    Richard

    #739122

    Hey!

    Thanks a lot for letting us know.
    Please remember to vote for Enfold at Themeforest, we would really appreciate it!

    Please feel free to let us know if we can do anything else for you.

    Regards,
    Basilis

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Sort blog posts in ascending order from category’ is closed to new replies.