In our WordPress tutorial series you have already seen how to install the WordPress core files and begin publishing content to your site in the form of posts, pages, media, etc. After reading this article you will know how to organize your posts alphabetically for your readers.

By default, WordPress will display published posts in the order they were published. This can be changed by adding a snippet of code to the functions.php file in the WordPress core configuration.

Bear in mind, editing the source code of your WordPress installation can be hazardous. Make sure to copy the code samples and paste them exactly.

Editing the "functions.php" File

You will need to access the functions.php file in the wp-content/themes folder for the WordPress theme you're using. In this example, I'm using the default "twentysixteen" theme.

Here is the code you will need:

function foo_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', 'foo_modify_query_order' );

Place the above snippet of text on the first available line after the initial comments.

How to alphabetize wordpress post

You can edit the functions.php file with any text editor or via FTP or the cPanel File manager.

After adding the code snippet, save the file, and reload your Wordpress front page. You'll now notice your posts diplay in alphabetical order on your front page.

This modification can also be applied to individual categories.

Word of Warning

Whenever editing the source code of any WordPress installation it is always wise to save a backup of the original file. An accidental edit can inadvertently wipe out critical data.

In the case of WordPress themes, you can keep an untouched copy in a safe location to be restored if necessary; or, if possible, you can re-download the source files from the developer.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}