WordPress.org

Ready to get started?Download WordPress

Forums

Sparkling
[resolved] Order posts by title ASC (3 posts)

  1. svsdnb
    Member
    Posted 2 months ago #

    Is there a way that I can order posts by title? Right now they appear to be ordered by date or ordered by title DESC but I don't see an array in the loop to order.

  2. Silkalns
    Member
    Theme Author

    Posted 2 months ago #

    This is not part of the theme but it can be done.

    Add this code to functions.php (preferably to Child theme functions.php )

    function sparkling_modify_query_order( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'orderby', 'title' );
            $query->set( 'order', 'ASC' );
        }
    }
    add_action( 'pre_get_posts', 'sparkling_modify_query_order' );
  3. svsdnb
    Member
    Posted 2 months ago #

    This worked perfectly! Than you!

Reply

You must log in to post.

About this Theme

About this Topic