Skip to content

Instantly share code, notes, and snippets.

Created August 1, 2018 14:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save davilera/b2d009e70677b99ae26da83852055174 to your computer and use it in GitHub Desktop.
Plugin Name: Sidebar Shortcode
Description: Two shortcodes for WordPress that will allow you to call sidebars or widget areas from the WordPress editor.
Plugin URI:
Author: Joe Casabona
Author URI:
Version: 1.1
License: GPL2
function jc_sidebar_shortcode($atts, $content="null"){
extract(shortcode_atts(array('name' => ''), $atts));
$sidebar= ob_get_contents();
return $sidebar;
add_shortcode('get_sidebar', 'sidebar_shortcode');
/** If you want just widgets and not the entire template! **/
function jc_widgets_shortcode($atts, $content=null){
extract(shortcode_atts(array('name' => ''), $atts));
if (is_active_sidebar($name)){
$widgets= ob_get_contents();
return $widgets;
return "";
add_shortcode('get_widgets', 'widgets_shortcode');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment