• I have a bunch of taxonomy-something.php pages that currently have blank sidebars–they’re not inheriting the sidebars with widgets that Posts within the theme have.

    How would I need to modify the code below to allow for sidebar widgets on taxonomy pages?

    /**
     * register sidebar
     */
    if ( ! function_exists( 'maple_ruby_register_sidebar' ) ) {
    	function maple_ruby_register_sidebar() {
    
    		if ( get_option( 'tn_custom_multi_sidebars', false ) ) {
    			$current_sidebar = get_option( 'tn_custom_multi_sidebars', '' );
    			if ( is_array( $current_sidebar ) ) {
    				foreach ( $current_sidebar as $sidebar ) {
    					register_sidebar( array(
    						'name'          => $sidebar['name'],
    						'id'            => $sidebar['id'],
    						'before_widget' => '<section id="%1$s" class="widget %2$s">',
    						'after_widget'  => '</section>',
    						'before_title'  => '<div class="widget-title"><h3>',
    						'after_title'   => '</h3></div>'
    					) );
    				}
    			}
    		}
    
    		register_sidebar( array(
    			'name'          => esc_html__( 'Full Width Top Footer', 'maple' ),
    			'id'            => 'tn_sidebar_top_footer',
    			'description'   => esc_html__( 'Full width area at top of footer area. Only allow {TOP FOOTER WIDGET] & custom html widgets.', 'maple' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<div class="widget-title"><div class="widget-title-inner"><h3>',
    			'after_title'   => '</h3></div></div>'
    		) );
    
    		register_sidebar( array(
    			'name'          => esc_html__( 'Footer 1', 'maple' ),
    			'id'            => 'tn_sidebar_footer_1',
    			'description'   => esc_html__( 'One of column of footer area', 'maple' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<div class="widget-title"><h3>',
    			'after_title'   => '</h3></div>'
    		) );
    
    		register_sidebar( array(
    			'name'          => esc_html__( 'Footer 2', 'maple' ),
    			'id'            => 'tn_sidebar_footer_2',
    			'description'   => esc_html__( 'One of column of footer area', 'maple' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<div class="widget-title"><h3>',
    			'after_title'   => '</h3></div>'
    		) );
    
    		register_sidebar( array(
    			'name'          => esc_html__( 'Footer 3', 'maple' ),
    			'id'            => 'tn_sidebar_footer_3',
    			'description'   => esc_html__( 'One of column of footer area', 'maple' ),
    			'before_widget' => '<section id="%1$s" class="widget %2$s">',
    			'after_widget'  => '</section>',
    			'before_title'  => '<div class="widget-title"><div class="widget-title-inner"><h3>',
    			'after_title'   => '</h3></div></div>'
    		) );
    	}
    }
    
    add_action( 'widgets_init', 'maple_ruby_register_sidebar' );
Viewing 1 replies (of 1 total)
  • You don’t have to modify the registration of the sidebars. You only need to look in the template file used by Posts (single.php?) and see where the sidebar is output. Copy the code for how the sidebar is output to your taxonomy templates. It should be something like is_dynamic_sidebar and get_sidebar.

Viewing 1 replies (of 1 total)
  • The topic ‘How to register sidebar on taxonomy template pages?’ is closed to new replies.