Want Different Sidebar for Different Category

If you trying to have different sidebar for different category then don’t worry it is possible without plugin. it just take your five minutes. not more then that.when i trying to add different sidebar for different category for the purpose of different advertisement display on different category.for that purpose i follow following steps and its work.

Step : 1

Make copies of your sidebar file
my default sidebar file name is rsidebar.php i make copies of that file and save with different name and also different advertisement code inside it.



Step: 2

Go back to your main sidebar file in this case my file was rsidebar.php and add following code at the start of file

<?php if (is_single(’276′))
{
include(“rsidebar1.php”);
?>

// this code for single post which have different sidebar   276  is post id

<?php } elseif (is_single(’114′) || is_single(’116′) || is_single(’118′) || is_single(’120′)|| is_single(’123′)|| is_single(’125′) || is_single(’127′)|| is_single(’44′) || is_single(’774′) || is_single(’778′) || is_single(’782′) || is_single(’785′) || is_single(’792′)|| is_single(’796′)|| is_single(’739′) || is_single(’129′))
{ //echo “ikram”;
include(“rsidebar2.php”);

?>

// this code for couple of pages have same  sidebar

<?php } elseif (in_category(68))
{
include(“ct.php”);
?>

// this code show for sidebar for particular category

 

<?php } elseif (in_category(96) || in_category(97) || in_category(98)|| in_category(99) || in_category(92))
{
include(“se.php”);
?>

 

// this is code group of category have same sidebar

<?php
//echo “important”;
}
else {
?>

// actual rsidebar.php content or code area //

<?php } ?> // end of the rsidebar.php file

Step 3 : everything is done now !

Share in top social networks!




Perfect Online WordPress Guide