• Hi,
    How do you do.
    I’m using “Twenty Nineteen” template(Latest version of WordPress). I added a new “Header widget” that is working perfect.
    I need another Header widget. The problem is that: When I duplicate codes in Function.php (with different Id and Name), my back-end and front-end goes white page.
    The question: How can I have more than 1 header,footer or sidebar widget in widget area?
    *Even I’ve used some plugin (like: Custom Sidebars or Widget Option) but there isn’t any controly where the put my content.
    ___________________________
    EXTRA INFORMATION
    I used this code to create first extra “Header Widget”:

    Added this code to Function.php:

    function wpb_widgets_init() { 
        register_sidebar( array(
            'name'          => 'Custom Header Widget Area',
            'id'            => 'custom-header-widget',
            'before_widget' => '<div class="chw-widget">',
            'after_widget'  => '</div>',
            'before_title'  => '<h2 class="chw-title">',
            'after_title'   => '</h2>',
        ) );
    }
    add_action( 'widgets_init', 'wpb_widgets_init' );
    
    <strong>Added this code to Header.php:</strong>
    <?php
    if ( is_active_sidebar( 'custom-header-widget' ) ) : ?>
        <div id="header-widget-area" class="chw-widget-area widget-area" role="complementary">
        <?php dynamic_sidebar( 'custom-header-widget' ); ?>
        </div>  
    <?php endif; ?>
    ___________________________

    I asked this question after three days wasted time. ??
    Sincerely
    Mendez

Viewing 3 replies - 1 through 3 (of 3 total)
  • Please show the entire code so we can see where you went wrong.

    You have defined a widget area. Widget areas can hold any number of widgets. That is done on the Widgets page. So you don’t need to add more code, just more widgets.

    Thread Starter medenz

    (@medenz)

    This the code is working perfect (with one widget that I’ve created). But when I try to create another widget, Back-end and Front-end goes white page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple header widget’ is closed to new replies.