How to add Another Sidebar in WordPress Blog?

Tuts Type : WordPress Coding
Level : Beginnear / Intermediate
Time : 10-15 Minitues

 

Most of the time, we use the wordpress readymate theme. That kind of theme are opensource that’s why we are using this. But, unfortunately in this case, we face some porblem. Most of the time, we get only 1 sidebar in admin panel. Sometimes we need add more in side bar but limitation of sidebar, we can not do this. Today I am going to teach how to add more side bar in your wp theme.

First of all, please download any free wp theme. After downloading the theme, install the theme as usally. Now, go to your directory where you have install the theme. For your kind infromation I am using Windows and Xampp. Normally it will store in you directory [Your dirve name]:/xampp/htdocs/wp/wp-content/theme/[your-new-theme-name].
Go to this theme and find out the functions.php file. Normally a file called functions.php are available in your directory. If not available, just open the notepad and create a new file called functions.php. Now write the following core in this file and save this.

<?php

if ( function_exists(‘register_sidebars’) ){

register_sidebars(1);

}

?>


Now, find the sidebar.php file in your directory. And then copy this file and save as sidebar1.php. Now write the below code.
<?php if ( function_exists(‘dynamic_sidebar’) && dynamic_sidebar(2) ) : else : ?>

<?php endif; ?>
Now, save the files and go to your wp admin by browser. Now go to Apperiance > Widget. I think, you are seeing two sidebar in your theme now. Am I right?
Ok, Now let’s go to our custom page where we have to add the new sidebar. I have created a page called ‘custom-login.php‘ in my theme directory. Now, I am going to add this widget in this page. The code are in below-

<?php

//Template Name: Custom Login Page

?>

<!– getting the header code–>
<?php get_header(); ?>

/*
|——————————————————————————-
| Adding new widget in your desire page
|——————————————————————————-
|
| I just included with sidebar1.php file in my desire page.
|
*/

<?php include (TEMPLATEPATH . ‘/sidebar1.php’); ?>

<!– getting the sidebar code –>
<?php get_sidebar();?>

</div>
<!–end the main body–>

<!– getting the footer code –>
<?php get_footer(); ?>

 

Now, save this page. And go to you site by browser. Now, check it. I think, it is ok now. This is the best way to add new widget in wp theme. Thanks for reading my tutorial. Best of Luck…

Advertisements

6 Comments

    • Hello @Ozan Aktamis

      for functions.php file, you can write your code anywhere in that file. It does not necessary that, you have to write your code on top or bottom. But make sure that, you code should not inside of other function or if condition.

      For sidebar1.php file, you can write your code anywhere also.
      and finally custom-login.php file, depends on your desire place, you can past your code. Based on your expectation, you will get based output.

      Thanks for reading….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s