Skip to main content

Forums

This topic contains 1 reply, has 2 voices, and was last updated by  uxfed 2 weeks, 2 days ago.

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

    amandajames
    Participant

    I am adding the following code to functions.php

    function wpblog_widget()
    {
        register_sidebar(array(
            'name' => __('Primary Sidebar', 'wpb'),
            'id' => 'primary_sidebar', // unique-sidebar-id
            'description' => '',
            'class' => '',
            'before_widget' => '<li id="%1$s" class="widget %2$s">',
            'after_widget' => '</li>',
            'before_title' => '<h2 class="widgettitle">',
            'after_title' => '</h2>',
        ));
    
    }
    
    add_action('widgets_init', 'wpblog_widget');
    

    This is to register a widget and to make the widget area visible I am dding this code in sidebar.php

    <?php if ( is_active_sidebar( 'Primary Sidebar' ) ) : ?>
    
        <?php dynamic_sidebar( 'Primary Sidebar' ); ?>
    
    <?php endif; ?>
    

    I don’t know why it is not working? I have seen the code here https://www.wpblog.com/how-to-add-custom-widget-area-to-wordpress-themes/

    #294117

    uxfed
    Participant

    Is your widget position showing in the backend? And if so, what have you tried to include in that widget position?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

icon-link icon-logo-star icon-search icon-star