Sidebar: Different for each page
-
Hi!
I need help. I want my sidebar to display different contents per page.
I’ve already created a Category called Sidebar… but it automatically places any post under this category on all pages with sidebars.I’d also placed a plug to make php codes work within a post.
I just need to know… what PHP codes will I put on each post to determine where page’s sidebar it will show?Thanks for the help!
-
I don’t understand the question? You want to display different content in the sidebar for different pages?
created a Category called Sidebar… but it automatically places any post under this category on all pages with sidebars.
That’s what confuses me.^^^
One way is to create Page Templates and new sidebar PHP files and use file includes to call those sidebars. For instance, lets say you have a page called “Contact” and want to include specific info in the sidebar on that page.
Create a new Page Template called “contact” (you can use your theme’s page.php file to guide you) and insert the following at the top…
<?php /* Template Name: Contact */ ?>Then when you create the contact page you can select the contact page template from the drop down menu.
Next, create a new sidebar.php file – call it whatever you want but for sake of simplicity lets call it contact-sidebar.php. Again, use your theme’s sidebar.php file to guide you.
In your newly created Contact Page Template use a file include like this…
<?php include (TEMPLATEPATH . '/contact-sidebar.php'); ?>More reading:
http://codex.wordpress.org/Pages
http://codex.wordpress.org/Pages#Page_Templatesworks good for me – to bad you can’t use different widgets for each page/sidebar – – or can u? (doubts it)
you can write different text in postmeta and call it in sidebar.
The topic ‘Sidebar: Different for each page’ is closed to new replies.