• Resolved Trampolini

    (@trampolini)


    What is the best way to add a widget to the header? Someone was able to create a widget on the top nav bar by creating an empty php file with some code. Would that apply here as well?

    I’d like to add the buddypress sign in and event finder on top. 🙂

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author Richie KS

    (@rkcorp)

    similiar concept with the previous top menu but different code add this in functions.php or create new file meso-custom-functions.php in wp-content/

    <?php
    function meso_add_new_widget() {
    register_sidebar(array(
        'name'=>__('Top Right Header', TEMPLATE_DOMAIN),
       	'id' => 'top-right-header',
    	'description' => __( 'Top Right Header widget area', TEMPLATE_DOMAIN ),
    	'before_widget' => '<div id="%1$s" class="widget %2$s">',
    	'after_widget' => '</div>',
    	'before_title' => '<p>',
    	'after_title' => '</p>',
    	));
    }
    add_action( 'widgets_init', 'meso_add_new_widget', 10 ); 
    
    function meso_add_top_right_header_widget() {
    if ( is_active_sidebar( 'top-right-header' ) ) {
    dynamic_sidebar( 'top-right-header' );
    }
    }
    add_action('bp_top_right_header','meso_add_top_right_header_widget');
    ?>

    open header.php go to line 113 and add this

    <?php do_action(‘bp_top_right_header’); ?>

    hi Trampolini, i just saw your reply in my thread..

    you should use a text editor to create a .php file (just name it .php)

    becareful not to use MS Word etc to do this. make sure the program u use is a proper text editor, whether for windows or mac. i’m on mac so i’m using TextEdit which comes with every Mac. goodluck!

    Thread Starter Trampolini

    (@trampolini)

    Hi, thanks for all your help. I was successful in creating a php (directly in the file manager) and the MENU widget worked! Yay! Now, I want to add a HEADER widget as described in this thread and it looks like you can’t have two new widgets. Adding the header code in functions in addition to the menu widget created an error:

    “Fatal error: Cannot redeclare meso_add_new_widget() (previously declared in /home/content/75/3966175/html/tvwatchparties/wp-content/themes/meso-child-theme/functions.php:31) in /home/content/75/3966175/html/tvwatchparties/wp-content/meso-custom-functions.php on line 12”

    Is there a way to correctly add code for both widgets?

    Thanks so much for your help!

    Thread Starter Trampolini

    (@trampolini)

    I figured it out! Yay. It was the code. I needed to get my brackets right. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding Widget to Header’ is closed to new replies.