谢谢你,TheDeadMedic。传奇
快速运行:
1) 为了让下面的代码正常工作,我创建了一个自定义帖子类型“carousel slide”,它还具有一个自定义分类“carousel slide category”
2) 在RoyalSlider滑块管理中,我创建了一个“Posts滑块”(管理菜单>RoyalSlider>编辑滑块>创建新滑块)。在这种情况下,滑块的ID为2。
3) 在主题函数中添加了下面的代码。php文件
4) 通过快捷码执行滑块
工作代码:
function rscustom_shortcode( $atts, $content = null ) {
    // Extract variables from shortcode attributes: post type, id, taxonomy
    $a = shortcode_atts( array(
        // \'rspt\' => \'\', Dont\' need now, but in case need to use other CPTs in future
        \'rsid\' => \'\',
        \'rstax\' => \'\',
    ), $atts );
    $rspt = trim($a[\'rspt\']);
    $rsid = trim($a[\'rsid\']);
    $rstax = trim($a[\'rstax\']);
    // Add Query Argument Filter
    add_filter( \'new_royalslider_posts_slider_query_args\',
        function ( $args ) use ( $rstax, $rspt ) {
            return array( 
                \'post_type\' =>  \'carousel-slide\', // $rspt 
                \'orderby\' => array(
                    \'menu_order\' => \'ASC\'
                ),
                \'tax_query\' => array(
                    array(
                        \'taxonomy\' => \'carousel-slide-category\',
                        \'field\' => \'slug\',
                        \'terms\' => $rstax,
                    ),
                ),
            );
        } 
    );
    // Execute the Royal Slider Query Override
    function newrs_custom_query($args) {
        return array( 
            \'post_type\' =>  \'carousel-slide\',
            \'orderby\' => array(
                \'menu_order\' => \'ASC\'
            ),
            \'tax_query\' => array(
                array(
                    \'taxonomy\' => \'carousel-slide-category\',
                    \'field\' => \'slug\',
                    \'terms\' => $rstax,
                ),
            ),
        ); 
    };
    return get_new_royalslider($rsid);
}
add_shortcode( \'rscustom\', \'rscustom_shortcode\' );