Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

How to create custom sidebar in wordpress without plugin

I’m going to show you how to add custom sidebars to your theme without using any plugins.

Step-1 : Register the sidebar

Here is the code , Paste this code in your function.php file of your active child theme (or theme).

add_action( 'widgets_init', 'theme_slug_widgets_init' );
function theme_slug_widgets_init() {
    register_sidebar( array(
   'name' => __( 'My Custom Sidebar'),
   'id' => 'my-custom-sidebar',
   'description' => __( 'Show widget newsletter' ),
   'before_widget' => '",
   'before_title' => '

', 'after_title' => '

', )); }

After added and save the functions.php file you can see them from Appearance -> Widgets.

Step-2 : Add the sidebar into the theme to display it

Now you have to do display the sidebar in to your website front-end. To do this add the below code in your sidebar.php file of your active child theme (or theme). This file name may be change and depending it according to your theme called.If you need to display this in another individual page you can add this that your page relevant position.


			

In the above php code, you must put your sidebar name by replacing the “My Custom Sidebar”.

Exit mobile version