Plugin in question: http://dimsemenov.com/plugins/royal-slider/wordpress/
Background: This is a great plugin, and it features a 'post' version where the slider pulls content from posts. However, the taxonomy for the posts that it's pulling has to be set at the slider settings level in WordPress, it can't be done via shortcode (that we know of). The plugin author does offer a way to override the default query here: http://help.dimsemenov.com/kb/wordpress-royalslider-advanced/wp-modifying-order-of-posts-in-slider
Aim: create a custom shortcode through which we can pass custom attributes, and specifically taxonomy, post-type.
Example of what the shortcode would look like: [rscustom rsid="2" rstax="home" rspt="carousel-slide"]
Our issue: probably a dumb one, but I can't get the shortcode variables to 'pass into' the query function, my code:
function rscustom_shortcode( $atts, $content = null ) {
// Extract variables from shortcode attributes: post type, id, taxonomy
$a = shortcode_atts( array(
'rspt' => '',
'rsid' => '',
'rstax' => '',
), $atts );
$rspt = trim($a['rspt']);
$rsid = trim($a['rsid']);
$rstax = trim($a['rstax']);
// Execute the Royal Slider Query Override
add_filter('new_royalslider_posts_slider_query_args', 'newrs_custom_query', 10, $rsid);
function newrs_custom_query($args) {
$args = array(
'post_type' => 'carousel-slide',
'orderby' => array(
'menu_order' => 'ASC'
),
'tax_query' => array(
array(
'taxonomy' => 'carousel-slide-category',
'field' => 'slug',
'terms' => "$rstax", // THIS VARIABLE ISN'T PASSING INTO THE FUNCTION
),
),
);
return $args;
};
return get_new_royalslider($rsid);
}
add_shortcode( 'rscustom', 'rscustom_shortcode' );
The line where I have...
'terms' => "$rstax"
...seems to be the bit where I'm hung up. When I have the line as...
'terms' => 'home'
...everything works wonderfully. I've looked into global variables, but just managed to confuse myself more.
Any and all help would be very, very much appreciated. Thanks in advance!