[WP] Modifying order of Posts in slider

There is new_royalslider_posts_slider_query_args filter (available since version 3.0.35), that allows filtering of query arguments.

For example, to filter posts by title:

If you want to modify existing WP_Query, for example set order by title:

// Important Note! The second parameter ($Index) is available only since RoyalSlider v3.1.6

add_filter('new_royalslider_posts_slider_query_args', 'newrs_custom_query', 10, 2);
function newrs_custom_query($args, $index) {
    // $args is WP_Query arguments object. 
    // feel free to change them here
    $args['orderby'] = 'title';

    // $index is an ID of slider that you're modifying

    return $args;

About arguments read more in WordPress codex - http://codex.wordpress.org/Class_Reference/WP_Query . Also, useful piece of code that contains all possible arguments with explanations - https://gist.github.com/luetkemj/2023628

Code can be added before slider output, for example in your theme functions.php.

If you want to run multiple post queries for one slider (or you need completely custom query):

Use new_rs_slides_filter. Example below will append posts with post_type=pages to your current slides:

function add_additional_posts_to_slider($slides, $options, $type) {
        // $options['id'] is a slider index

    $args = array(
        'post_type' => 'page'
    $query = new WP_Query($args);
    $additiona_slides = (array)$query->posts;
    if( is_array($additiona_slides) ) {
        $slides = array_merge($slides, $additiona_slides);
    return $slides; // slides is array of WP Post objects that will be displayed in slider
add_filter('new_rs_slides_filter', 'add_additional_posts_to_slider', 10, 3);


If the code that you added isn't working or running, make sure that slider isn't cached (set cache refresh time to 0 on RoyalSlider Settings page, or preview it in admin).