BEFORE you read further : Make a backup copy of all your files. In case you accidentally make a mistake, you will be able to restore the backup files.
Do you want to have different sidebars in a WordPress blog for different typed of contents? Like different side bars for posts, pages and homepages.
Here is a simple fix:
- Backup all the files (to be safe)
- Find "sidebar.php" file in your theme folder.
- Make a copy of the "sidebar.php" and rename it to something like "sidebar-no2.php". WordPress naming convention is "sidebar-NAME.php". You can have any NAME.
- Make changes required to the "sidebar-no2.php". Upload to the server.
- Find the file ‘single.php’ (if you want posts to have different sidebar) and open it.
- Find <?php get_sidebar(); ?> and change it to <?php get_sidebar(‘no2’); ?>. Make sure the text between single quote marks ‘ is the NAME you have used after ‘ – ‘ in the name of new sidebar file.
- Save you ‘single.php’ file (or ‘page.php’ etc.) and upload it to the server.
Now, when you open your wordpress blog, Homepage will show the sidebar of ‘sidebar.php’ and when you open a single post, the contents of ‘sidebar-no2.php’ will be displayed.
Note of caution: If you have dynamic content in the side bar (almost all themes have that), you should remove the part – <?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar() ) : ?>.
To use dynamic sidebar contents in two different sidebar involves editing "functions.php."
Different Widget Ready sidebars:
Two step process:
- Edit functions.php to register the sidebars to WordPress backend to tell there are two sidebars ready for widgets.
- Edit each sidebar.php page ready to pull in the widgets.
I will update this section later.