Choose Your Wordpress sidebar

Choose Your Wordpress sidebar

wordpress-logo-shineOne of the main issues with Wordpress is it’s lack of some CMS capabilities.

There are times when you need different sidebars for different pages or posts.

This is a simple Wordpress hack to add that functionality.

Simply open single.php* and find the call to the get_sidebar() function:

<?php get_sidebar(); ?>

Swap it out with:
<?php $sidebar = get_post_meta($post->ID, "sidebar", true);
get_sidebar($sidebar);
?>

When you write a post now you just have to create a custom field and add the name of the sidebar.
Example: aboutus and it will include aboutus.php

People who read this also read:
  • Password Protect Your Entire Wordpress Website
  • Wordpress Show Parent Title if Showing Children Pages
  • How to add Adsense ads Between wordpress Post
  • 10 Great Wordpress Hacks & Tricks
  • Best SEO Permalink Structure
  • WordPress Under Attack
  • Auto Update Copyright Date In Wordpress Footer With PHP
  • If you have any questions, addtional information, or found this helpful "Leave a Comment" below.
    blog comments powered by Disqus