• Resolved dierofly

    (@dierofly)


    Hello, I would like to know if it is possible to include widget in Extras area? I was thinking about using WP Custom Widget area plugin and use the shortcode from this plugin in Extras area of the theme.

    Unfortunately shortcode is not displaying in Extras area. Is there a way how to make shortcodes work in Extras area?

    Kind regards

Viewing 1 replies (of 1 total)
  • Theme Author simplethemes

    (@simplethemes)

    The best way to do this is to create (register) a new widget location to hold your widget:

    function my_extra_sidebar() {
    	register_sidebar( array(
    		'name'          => __( 'Extra Widget Area', 'smpl' ),
    		'id'            => 'my-extras-sidebar',
    		'description'   => __( 'Extra widget area', 'smpl' ),
    		'before_widget' => '<div id="extras-widget" class="%1$s">',
    		'after_widget'  => '</div>',
    		'before_title'  => '<h3 class="widget-title">',
    		'after_title'   => '</h3>',
    	));
    }
    add_action( 'widgets_init', 'my_extra_sidebar' );

    Now, we can hook it into the skeleton_child_header_extras() filter:

    function show_my_extra_sidebar() {
    	do_shortcode(dynamic_sidebar( 'my-extras-sidebar'));
    }
    add_filter('skeleton_child_header_extras','show_my_extra_sidebar');

    Notice we wrapped it in do_shortcode() so that shortcodes will work inside the widgets. We also gave it an id of #extras-widget so the CSS would look something like:

    #extras-widget {
    	float: right;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Use widget in Extras area?’ is closed to new replies.