Works for Category…Need it to do same for pages
-
What the code below does is when a category is selected it loads a particular sidebar based on the parent category. It is working fine (let me know if you see any deprecated code.)
Now the same thing needs to be done for pages, so when a particular page is loaded a particular side bar needs to be loaded.
Would appreciate help in converting/creating code that determines the page ID, then loads the appropriate sidebar. This time though it needs a if/else condition since the sidebar # corresponds to the categories and not the pages.
<?php
$cat_object = $wp_query->get_queried_object();
$cat_parent = $cat_object->category_parent; ?>
<?php include (‘sidebar’.$cat_parent.’.php’); ?>
- The topic ‘Works for Category…Need it to do same for pages’ is closed to new replies.