Previous Tutorial -> http://1wmedia.blogspot.in/2016/04/creating-sidebar-template-by-using.html
In this tutorial we will see how to create sidebar using register_sidebar function.
1. Open your functions.php file from your themes folder.
2. Add the following code to widget support for your theme.
<?php
//adding Widget:
add_theme_support( 'widgets' );
?>
3. Open Dashboard -> Appearance -> Here you can see widgets.
4. Now go to your functions.php and add the following code for creating or registering sidebar
<?php
register_sidebar(array(
'name' => 'Sidebar Name',
'id' => 'sidebar-id',
'description' => 'This is description of Sidebar Name',
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
?>
save the functions.php
5. name -> naming the sidebar, id -> to call/add the sidebar wherever you want by using this id, description -> for giving the description of the sidebar.
6. Now view widgets in dashboard -> You will see one widget with following name, "Sidebar Name"
7. Add some widgets and save it.
8. Now we will call / add this widget in your template or wherever you want.
9. In our case we will add this into page-sidebar template. So open the page-sidebar.php file.
10. Paste the following code below "<div class="col-md-4" > "
<p><?php if( dynamic_sidebar('sidebar-id')); ?></p>
11. Here "sidebar-id" is an id, we have created earlier in register_sidebar function (point no 4)
12. Now view the page -> with Sidebar Template selected.
13. You can see the sidebars.
Please refer the following video:
In this tutorial we will see how to create sidebar using register_sidebar function.
1. Open your functions.php file from your themes folder.
2. Add the following code to widget support for your theme.
<?php
//adding Widget:
add_theme_support( 'widgets' );
?>
3. Open Dashboard -> Appearance -> Here you can see widgets.
4. Now go to your functions.php and add the following code for creating or registering sidebar
<?php
register_sidebar(array(
'name' => 'Sidebar Name',
'id' => 'sidebar-id',
'description' => 'This is description of Sidebar Name',
'before_widget' => '<div class="widget">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
?>
save the functions.php
5. name -> naming the sidebar, id -> to call/add the sidebar wherever you want by using this id, description -> for giving the description of the sidebar.
6. Now view widgets in dashboard -> You will see one widget with following name, "Sidebar Name"
7. Add some widgets and save it.
8. Now we will call / add this widget in your template or wherever you want.
9. In our case we will add this into page-sidebar template. So open the page-sidebar.php file.
10. Paste the following code below "<div class="col-md-4" > "
<p><?php if( dynamic_sidebar('sidebar-id')); ?></p>
11. Here "sidebar-id" is an id, we have created earlier in register_sidebar function (point no 4)
12. Now view the page -> with Sidebar Template selected.
13. You can see the sidebars.
Please refer the following video:
No comments:
Post a Comment