How to add sidebar according to category wise in wordpress
Technology 0 CommentsSide bar show according to category wise and Display Different Sidebar for category wise and also show different category in Page wise in WordPress
WordPress posts show from a particular category wise in sidebar. How to different content in show in different Sidebar Content Throughout Your WordPress Site
How to add sidebar according to category wise in WordPress show WordPress code
<?php
if ( (in_category(’33’))) {
echo “jgk”;
include(TEMPLATEPATH . ‘/sidebartest.php’);
} else {
echo “jgk”;
}
?>
33 is category id
<?php
if ( (in_category(’33’))) {
echo “jgk”;
include(TEMPLATEPATH . ‘/sidebartest.php’);
} elseif ( (in_category(’34’))) {
include(TEMPLATEPATH . ‘/sidebartest2.php’);
} else {
echo “jgk”;
include(TEMPLATEPATH . ‘/sidebar.php’);
}
?>
<?php if ( is_page(‘Section 1’) || $post->post_parent == ‘1’ ) { ?>
<p> Custom content for “Section 1″</p>
<?php } elseif ( is_page(‘Section 2’) || $post->post_parent == ‘2’) ) { ?>
<p> Custom content for “Section 2″</p>
<?php } else { ?>
<p> Generic sidebar content</p>
<?php } ?>
Sidebar include according to page and custom page in WordPress
<?php get_header(); ?>
<?php include(TEMPLATEPATH."/left.php");?>
<div id="content">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div>
<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
</div>
<?php endwhile; endif; ?>
</div>
<?php include(TEMPLATEPATH."/right.php");?>
<?php get_footer(); ?>
Page wise according to category
<?php if ( is_page('about')) { ?>
<ul>
<?php wp_list_cats('exclude=4, 5, 6, 7, 8'); ?>
</ul>
<?php } elseif ( is_page('gallery')) { ?>
<ul>
<?php wp_list_cats('exclude=1, 2, 3, 7, 8'); ?>
</ul>
<?php } else { ?>
<ul>
<?php wp_list_cats('exclude=1, 2, 3, 4, 5, 6'); ?>
</ul>
<?php } ?>
Daily Visit GK on myshort.in