[Support request] Alphabetizing Posts in Categories

Home Forums Support [Support request] Alphabetizing Posts in Categories

Home Forums Support Alphabetizing Posts in Categories

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1643270
    K Bell

    Hello,

    My site is a dictionary, with a category for each letter.

    The plugin I am using to alphabetize posts has been deprecated.

    WordPress provides these directions to change the categories.php file to achieve the same effect. However, I cannot find the Category Template within the theme editor.

    How would I make all categories sort alphabetically within this theme?

    Thank you,

    Kenton

    #1643592
    Elvin
    Staff
    Customer Support

    Hi,

    I’m not sure I fully understand what you mean.

    To clarify: Do you want the post lists to be sorted alphabetically by title?

    If so, from the same page you’ve linked, you can use pre_get_posts.

    Example: Sorting archives using title in ascending order.

    function modify_query_order( $query ) {
        if ( $query->is_archive() && $query->is_main_query() ) {
            $query->set( 'orderby', 'title' );
            $query->set( 'order', 'ASC' );
        }
    }
    add_action( 'pre_get_posts', 'modify_query_order' );

    Here’s how to add PHP: https://docs.generatepress.com/article/adding-php/

    A wise man once said:
    "Have you cleared your cache?"

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