[Resolved] sort posts alphabetic

Home Forums Support [Resolved] sort posts alphabetic

Home Forums Support sort posts alphabetic

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

    Hi,
    hopefully the last question for this project:
    Is it possible to sort the category posts only for the category-id18 “kuenstlerinnen” (category page link in Private information) in alphabetic order?
    Thanks ahead,
    Torsten

    #2372534
    David
    Staff
    Customer Support

    Hi there,

    try this PHP Snippet:

    
    function db_abc_modify_query_order( $query ) {
        if ( $query->is_category( 'your-category-slug' ) && $query->is_main_query() ) {
            $query->set( 'orderby', 'title' );
            $query->set( 'order', 'ASC' );
        }
    }
    add_action( 'pre_get_posts', 'db_abc_modify_query_order' );

    Make sure to update the your-category-slug in the code

    #2372537
    Torsten

    THANKS!

    #2372541
    David
    Staff
    Customer Support

    You’re welcome

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.