[Support request] Display custom sidebar on category pages

Home Forums Support [Support request] Display custom sidebar on category pages

Home Forums Support Display custom sidebar on category pages

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1093002
    Hilton

    Hi,

    I used the code below to register a new sidebar and display into category pages. The sidebar was registered, but I can’t see it in the categories of the site.

    if ( function_exists('register_sidebar') ) {
    	register_sidebar(array(
    		'name' => 'Categorias',
    		'id' => 'categorias-sidebar',
    		'description' => 'Sidebar for categories',
    		'before_widget' => '<li id="%1$s">',
    		'after_widget' => '</li>',
    		'before_title' => '<h2>',
    		'after_title' => '</h2>',
    	));
    }
    
    add_filter( 'generate_sidebar_layout', function( $layout ) {
        // If we are on a category, set the sidebar
        if ( is_category() ) {
            return 'categorias-sidebar';
        }
    
        // Or else, set the regular layout
        return $layout;
     } );
    #1093470
    Leo
    Staff
    Customer Support

    Hi there,

    Looks like you’ve opened a similar topic here:
    https://generatepress.com/forums/topic/create-a-custom-sidebar-for-archives-pages/

    Let’s stick with that one 🙂

    Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.