Sometimes it is useful to include WordPress Sidebar in a Content Template or a View. It is possible to build a shortcode to display it:
// Display WP Sidebar shortcode add_shortcode('wpv-dynamic-sidebar', 'my_sidebar_shortcode'); function my_sidebar_shortcode($atts) { ob_start(); $a = shortcode_atts( array( 'sidebar' => 'sidebar-1', ), $atts ); dynamic_sidebar($a['sidebar']); return ob_get_clean(); }
dynamic_sidebar() reference: https://developer.wordpress.org/reference/functions/dynamic_sidebar/
Then I can use this shortcode anywhere:
[wpv-dynamic-sidebar]
By default this displays the default sidebar or ‘sidebar-1’. It is also possible to pass another sidebar name by the attribute “sidebar”. For example:
[wpv-dynamic-sidebar sidebar="footer-1"]
You can find this solution on this Toolset forum thread:
https://toolset.com/forums/topic/insert-sdiebar-in-views-template/