• I have searched everywhere and worked several hours trying to add a widgetized area to my page without success. Could anyone please help?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello @skilgore

    You should always search the codex !
    Widgetizing Themes
    If you need more help don’t hesitate.

    SYA ??

    Thread Starter skilgore

    (@skilgore)

    I did read that article, unfortunately, I am still lost.

    Hello @skilgore

    First of all, when you want to customize a theme, always create a child theme.
    If you don’t and modify the main theme that you are using, then all your customization will be lost on the next update of the main theme.

    To add a widgets area :
    1- In the functions.php file of the theme put the following :

    /**
     * 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' ); 

    This will tell WP that you have a new widgets area named Home right sidebar that have an id of home_right_1

    Than, in your sidebar.php add :

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

    This will tell WP, show my widgets area that I’ve created earlier with an id of home_right_1 if their is widgets in it.

    Then, you have to choose the location where you want to display this widgets area.
    For example, you wish to add it to all of your pages, depending the theme you are using (since you are not telling wish one… and not giving a link to your website), you’ll have to search wish template is used to display pages if page.php is linking to another file.
    Assuming that it’s page.php, you can add the following exactly where you wish to display the widgets area :
    <?php dynamic_sidebar( 'home_right_1' ); ?>

    Of course, you’ll have to style it as you need.

    SYA ??

    • This reply was modified 8 years, 3 months ago by LebCit.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding additional widgetized area’ is closed to new replies.