• Hello all,
    Site: https://1.projecthappiness.com

    I am looking to add a widget area as the top bar. I have a plugin top bar but am thinking a widgetized area would be more flexible.

    I have looked and looked, and the code I found for doing so is 6 years old. Is there a whiteboard somewhere here or a tutorial on how to do this?

    Thanks

Viewing 1 replies (of 1 total)
  • It is particularly simple to add a new area of widgets below some sample code and paramais information visit the codex.

    In functions.php

    <?php
    /**
     * Register our sidebars and widgetized areas.
     *
     */
    function arphabet_widgets_init() {
    
    	register_sidebar( array(
    		'name' => 'Home right sidebar',
    		'id' => 'home_right_1',
    		'before_widget' => '<div>',
    		'after_widget' => '</div>',
    		'before_title' => '<h2 class="rounded">',
    		'after_title' => '</h2>',
    	) );
    }
    add_action( 'widgets_init', 'arphabet_widgets_init' );
    ?>

    In header.php or other file where the area will appear.

    <?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
    	<div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
    		<?php dynamic_sidebar( 'sidebar-1' ); ?>
    	</div><!-- #primary-sidebar -->
    	<?php endif; ?>

    Example taken from the codex.

Viewing 1 replies (of 1 total)
  • The topic ‘Adding a Top Bar (Widget area?)’ is closed to new replies.