Home Internet web designing Easy Way To Add Custom Sidebar In WordPress

Easy Way To Add Custom Sidebar In WordPress


If someone want a good looking and good navigation wordpress website then he required custom sidebar in wordpress pages.If you required custom sidebar for different pages of WordPress, i have some simple steps to do this.

Four Steps to add custom sidebar in wordpress

Create Custom Sidebar File

File manager In cPanel
File manager In cPanel

Go to Theme Folder In Cpanel: Login to Cpanel admin area.after that click on file manager.Click on folder public_html under the file manager .Locate your website root folder.For example i added my website tectrick.org under public_html>tectrick.org.Click the open the root folder.Locate the folder wp-content .Click to open it.Now click on the folder “themes” to open it.Click on the theme name,which them is installed in wordpress.For example i installed theme name “tectrick”. So i click on folder tectrick.

Go to installed theme folder
Go to installed theme folder

Create New .php File For Custom Sidebar: Create a new file by click on new file icon at left upper side of screen.In the new file name field write “sidebar-home.php”.If you want to create one more side bar then create anothor file with the name “sidebar-single.php”.You can choose any name for custom sidebar.But take care before choose sidebar name.First world must be “sidebar” and saperated by hyphen sign (-) from second word. Example name : sidebar + “-” +home + .php = sidebar-home.php.

READ ALSO : -  How To Install Theme In Wordpress Via Dashboard Or Using FTP File Uploads
Create Sidebar.php file
Create Sidebar.php file

Go to sidebar.php file in the .php files.Click to open it. Copy all content of the sidebar.php. Paste this copied content to sidebar-home.php file.Find the following code in sidebar-home.php

<?php if (function_exists(‘dynamic_sidebar’) && dynamic_sidebar(‘Sidebar Widgets‘)) : else : ?>

Replace above code with following code or only change sidebar name in the code.

<?php if (function_exists(‘dynamic_sidebar’) && dynamic_sidebar(‘Sidebar Home‘)) : else : ?>  Click update to save file.

Edit Custom Sidebar In WordPress Dashboard
Edit Custom Sidebar In WordPress Dashboard

Register The Custom Sidebar in WordPress

Write Function to register sidebar: After create a blank php file “sidebar-home.php” go to wordpress dashboard.Go to “Appearance” and then “Editor”.In the file list click on “functions.php” .Copy the red colored text function code at the end on function.php before ” ?> ” .

* Register our sidebars and widgetized areas.
function arphabet_widgets_init() {

register_sidebar( array(
‘name’ => ‘Sidebar Home’,
‘id’ => ‘sidebar-home’,
‘before_widget’ => ‘<div class=”widget”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’,
) );

add_action( ‘widgets_init’, ‘arphabet_widgets_init’ );

With this function your sidebar is registered in wordpress widgets.

READ ALSO : -  Wordpress Guide-Add New User From Dashboard
register sidebar in widgets
register sidebar in widgets

Add custom sidebar in wordpress page: Now you can use this custom sidebar in wordpress pages.For example if you want to use custom sidebar on home page then go to Appearance>Editor . In the editor section click on index.php file to open it.At the end of the code change the  <?php get_sidebar(); ?> code into <?php get_sidebar(‘home’); ?>.

custom sidebar is added in wordpress
custom sidebar is added in wordpress

Now Custom sidebar in wordpress is active on homepage.with this way you can create different sidebars for different pages.