scottymorg
scottymorg

Reputation: 133

Custom sidebar for every page/post in wordpress

I would like to ask if there is any way to have customizable sidebar for every page/post. For example, the default sidebar is set for normal page or post but what if I would like to change it to use another sidebar that I have created? My idea is,

  1. Register sidebars that I would like to use.
  2. Add custom meta field to page/post editor to call the list of the sidebars I have created
  3. When I create new page/post I will just select the sidebar I want and it will show up on that page/post

I have the idea but unfortunately I have no idea how to code it into the template. Is there any tutorial or something I should look up to?

Sorry if my question is confused, I hope you understand.

Thank you

Upvotes: 0

Views: 188

Answers (1)

Manindra Singh
Manindra Singh

Reputation: 769

if you want to use different sidebar on different pages then you can use this code in your template file.

<?php if(is_page(YourPageID))
{

//include your sidebar here

}elseif(is_page(YourPageID)){

//include your sidebar here

 }
 ----------
 ----------
?>

Upvotes: 1

Related Questions