If you are using a single articles page (single.php) and would like to use a different sidebar on those pages, look no further. The answer is extremely easy and useful in many cases.
First of all, make sure that you are using a single.php page. If you are not then there is no reason to go further.
Okay, let’s assume that you are using a single.php file. Open it up with your favorite code editor and go to the point where it reads:
<?php get_sidebar(); ?>
and replace it with:
<?php if ( is_single()) {
get_sidebar(single);
} else {
get_sidebar();
}
?>
The above code tells WP that if the page requested is “single.php” then the “sidebar-single.php” should be used. In any other case, the normal sidebar will be used.
Ok, now that you did that create a new “sidebar-single.php” file (without the double quotes of course). You can copy your existing “sidebar.php” file and save it as “sidebar-single.php”.
Now, head over to your stylesheet and style the new sidebar as well.
That’s about it! Enjoy
customize, sidebar.php, single.php, wordpress