If you need to order your post alphabetically from A to Z or from Z to A in archive page. Then you need to hook to pre_get_post and modify the function parameter – $query object. To be precise, you need to set orderby and order properties. Do that using $object->set(k, v) method. Simple, add this code to your function.php file. In my case, I use products custom post type created in CPT UI plugin (but it works for every custom post type).

 * Change the order of posts/pages/cpt in the Divi Blog module
 * @see https://www.youtube.com/watch?v=awg0gUfxC0c -> fix in comment by Wiktor Liszkiewicz
function paChangeBlogModuleOrder($query)
    // $result = array_key_exists('products', $query->query); 
    // echo "<pre>";
    // var_dump($query->query);
    // echo "<br>";
    // echo "</pre>";
    if (array_key_exists('products', $query->query)) {
        // echo "custom sorting on!";
        $query->set('orderby', 'title');
        $query->set('order', 'ASC');
add_action('pre_get_posts', 'paChangeBlogModuleOrder');

The debug of $query->query would like something liek that:

array(1) {
  string(16) "design-materials"


Would love your thoughts, please comment.x