/**
 * Divi Blog-Modul: Beiträge zufällig sortieren (nur wenn CSS-ID = random-posts)
 */
add_filter('et_builder_blog_query', function($query, $args) {

    // Nur wenn die Modul-ID passt
    if (!isset($args['module_id']) || $args['module_id'] !== 'random-posts') {
        return $query;
    }

    // Divi übergibt manchmal WP_Query, manchmal Array-Args – wir behandeln beides
    $vars = ($query instanceof WP_Query) ? $query->query_vars : (array) $query;

    // Random
    $vars['orderby'] = 'rand';
    $vars['order']   = 'ASC';
    $vars['ignore_sticky_posts'] = true;

    // Ergebnis zurück in WP_Query
    return new WP_Query($vars);

}, 10, 2);