I have a CMS website in Wordpress, however for different pages and posts on there i would like to display different sutff on the sidebar depending on what page you are on.
At the moment the same information is displayed in the sidebar for all pages and posts, however i would like it so that different pages/posts have sidebar info relating to that particular page/post?
Anyone know how to do this, or where i would start?
Cheers
Paul
Page 1 of 1
Wordpress Different Sidebar on different pages/posts? How to?
#2
Posted 03 September 2010 - 08:26 AM
The best way to do this, that i know of, is to make use of the custom fields.
If you open your single.php page, or post.php page in an editor you will be able to find the line:
You want to be able to edit this so that it can acquire the information needed to display the correct sidebar. So replace with:
Now, to display a custom sidebar in a post or page; add the custom field “sidebar” and include the name of the sidebar file. E.g. if you insert “test”, it will display
sidebar-test.php as your sidebar.
I hope that makes sense, however, i just realised... you will need to have the ability to enable widgets in more than one sidebar. Check out this tutorial on how to do so:
Multiple Sidebars Wordpress
If you open your single.php page, or post.php page in an editor you will be able to find the line:
<?php get_sidebar(); ?>
You want to be able to edit this so that it can acquire the information needed to display the correct sidebar. So replace with:
<?php $sidebar = get_post_meta($post->ID, "sidebar", true); get_sidebar($sidebar); ?>
Now, to display a custom sidebar in a post or page; add the custom field “sidebar” and include the name of the sidebar file. E.g. if you insert “test”, it will display
sidebar-test.php as your sidebar.
I hope that makes sense, however, i just realised... you will need to have the ability to enable widgets in more than one sidebar. Check out this tutorial on how to do so:
Multiple Sidebars Wordpress
Share this topic:
Page 1 of 1
Help
















