Hi.. Im doing a client's website, who has 10 different posts on the main nav bar and on those 10 different posts pages, he needs different elements on each of their sidebars on those posts pages. So, how do we do that ? P.S : Im asking posts, not pages. This is not a blog and a company website. And he is not using WP pages for his site pages, but WP posts.
use Conditional Tags and create widget for each post is_single() http://codex.wordpress.org/Conditional_Tags Code (markup):
Hi.. Thanks for your reply. Can you just do a sample example , Like, if the Post-ID is 15 and the post slug is, about-us. And we want on sidebar, <b>xyz</b>
Well, this is the way to Accomplish this the easiest way!! <?php $homepage = "URL TO THE POST TO SHOW <b> XYZ</b>/"; $currentpage = $_SERVER['REQUEST_URI']; if($homepage==$currentpage) { echo "<b>xyz</b>"; } ?> Code (markup): You should put this in the Sidebar.php to get it on the sidebar!! you can use the Divs, or insert between the existing Divs to stylize it!! So If you have 10 posts, You should Copy these 10 times with the Required url and the content needed. Out of those 10, in which homepage=currentpage gets validated, will be echoed, rest will be avoided!! Got it? Whoosh!! That was hard Typing!! ~ExP~
if (is_single(15)) { <div id="custom-widget" class="widget-area" role="complementary"> <ul class="xoxo"> <?php dynamic_sidebar( 'custom-widget-area' ); ?> </ul> </div> } else { <?php get_sidebar(); ?> //default sidebar } Code (markup):
You Managed It from the Wordpress Aspect !! But I considered it as a Php supported Website Good Work In The End!! ~ExP~ ADDITION: You can use this to do all at a Go!! <?php if (is_page('1')) { include("sidebar3.php"); } elseif (is_page('green-page')) { include("sidebar2.php"); } elseif (is_page('another-page')) { include("sidebar3.php"); } else { include("sidebar.php"); } ?> Code (markup):
custom-widget-area Where does that widget exist ? I dont think, WP allows you to make multiple widget groups.
register_sidebar( array( 'name' => __( 'custom Widget Area', 'bhuthecoder' ), 'id' => 'custom-widget-area', 'description' => __( 'The custom widget area', 'bhuthecoder' ), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>', ) ); Code (markup): put this code in function.php (located in themes folder) it will create a widget with name "custom Widget Area" and u can call this widget using below code <?php dynamic_sidebar( 'custom-widget-area' ); ?> Code (markup):