All Collections
FAQ's and Troubleshooting
Reorder Post Types In The Divi Blog Module
Reorder Post Types In The Divi Blog Module

Control the order of the blog posts on the Divi Blog module.

Marius avatar
Written by Marius
Updated over a week ago

The Blog module displays posts in chronological order, while other post types like projects, pages, or custom post types aren't sorted based on their publication date.

With this trick, you will be able to arrange them all chronologically.

Note: This tutorial requires a child theme

After the child theme is installed and active, add this code in functions.php:

add_action('pre_get_posts', 'divi_change_blog_module_order');
function divi_change_blog_module_order($query) {
$pac = get_query_var( 'post_type' );
if ( 'post' == $pac )
{
$query->set('orderby', 'title');
$query->set('order', 'ASC');
}
}

divi child theme

The code will arrange the items in alphabetical order, starting from A and ending at Z.

Other Post Types

The Blog module can display other post types. If you plan to use them, changes in the code need to be made. Simply replace 'post' with the relevant post type you are using. For example, use 'page' for pages or 'projects' for projects.


โ€‹

Invert the Order

If, for any reason, you wish to display the items in the reverse order, you can modify the 'ASC' in the code snippet. Just replace 'ASC' with 'DESC,' and the items will be shown from Z to A.

Did this answer your question?