in ,

Create Widget Area For Your WordPress

In WordPress has widget area where the widget can add. Widget area is normally in right side of main content area or in left side of it. Create widget area is make more slot for widgets to be placed over them in the admin widgets area. In this article I show you how to create widget area with few step.

You can find “Widgets” under the tab “Appearance” in Admin panel: Appearance -> Widgets

How to Register a Widget Area

The following should be added to your Theme’s functions.php file:

[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’ );
?>

[/php]

[notification type=”alert-warning” close=”true” ]Note: I have added prefix arphabet_ to function name at two places at top and at bottom.You can change to a prefix of your choice.[/notification]

How to display new Widget Areas

Once you have enabled the function in function.php you can make any area as a widget area within a WordPress theme. Add following code to location of your choice in your theme file. (Ex: sidebar, footer, header)

[php]<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘home_right_1’) ) :

endif; ?>[/php]

[notification type=”alert-warning” close=”true” ]NOTE: If you want more then one area to be widgetized at the same time, then you have to register sidebar in function.php more then once with different names and id’s [/notification]

What do you think?

Written by Sopheap

The goal of me is sharing new ideas, inspiration art, fresh and useful resource, covering web design and development, graphic design, advertising, mobile development and life style.

Comments

Leave a Reply

Your email address will not be published.

display useful button wp edtior

Display Useful Button In WordPress Editor

Display Breadcrumbs To Your WordPress Website ~ Sopheap

Display Breadcrumbs To Your WordPress Website