• christoph-ED

    (@webagenturerding)


    I want to register new Sidebar with the Plugin.
    If i do it in the function.php it works.

    With code snippets not?
    Whats going wrong?

Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    You can register a new sidebar as a snippet like this:

    add_action( 'widgets_init', function () {
    
    	register_sidebar( array(
    		'id'            => 'unique-sidebar-id', // make sure this is lowercase and unique
    		'description'   => 'Sidebar description.',
    		'before_widget' => '<li id="%1$s" class="widget %2$s">',
    		'after_widget'  => '</li>',
    		'before_title'  => '<h2 class="widgettitle">',
    		'after_title'   => '</h2>'
    	) );
    
    } );

    Of course, you will still need to output it somewhere in your theme. If you want to display it in a post/page content, you can add it as a shortcode:

    add_shortcode( 'my_sidebar', function () {
    	ob_start();
    
    	dynamic_sidebar( 'unique-sidebar-id' );
    
    	return ob_get_clean();
    } );
Viewing 1 replies (of 1 total)
  • The topic ‘Register Sidebar dont work’ is closed to new replies.