Home » » How to register widget in wordpreses

How to register widget in wordpreses

Register Widgets WordPress is use for geting you element widgete in your WordPress themes sidebars to put in specific place in your site and it make you easy to control you site my drag and drop in admin dashboard. You can also modify your theme and start Customizing Your Sidebar as you can use the following code below.
1.go to funcitons.php in root directory of your thames and put to this example code:

function my_widgets_init() {
require get_template_directory() . '/inc/widgets.php';
register_widget( 'Twenty_Fourteen_Ephemera_Widget' );

register_sidebar( array(
'name'          => __( 'Primary Sidebar', 'twentyfourteen' ),
'id'            => 'sidebar-1',
'description'   => __( 'Main sidebar that appears on the left.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget'  => '</aside>',
'before_title'  => '<h1 class="widget-title">',
'after_title'   => '</h1>',
) );
register_sidebar( array(
'name'          => __( 'Content Sidebar', 'twentyfourteen' ),
'id'            => 'sidebar-2',
'description'   => __( 'Additional sidebar that appears on the right.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget'  => '</aside>',
'before_title'  => '<h1 class="widget-title">',
'after_title'   => '</h1>',
) );
register_sidebar( array(
'name'          => __( 'Footer Widget Area', 'twentyfourteen' ),
'id'            => 'sidebar-3',
'description'   => __( 'Appears in the footer section of the site.', 'twentyfourteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget'  => '</aside>',
'before_title'  => '<h1 class="widget-title">',
'after_title'   => '</h1>',
) );
}

add_action( 'widgets_init', 'twentyfourteen_widgets_init' );

*using:
<?php 
if ( is_active_sidebar( 'sidebar-2' ) ) : 
dynamic_sidebar( 'sidebar-2' ); 


endif; 
Share this acticle :

0 comments:

Post a Comment

 

Proudly powered by Blogger