• Resolved Storyman

    (@storyman)


    There are 6 different main categories and a couple of dozen sub-categories for each main category. So, creating a ‘category-#.php’ page for all of the sub-category pages kills the idea of a dynamic site.

    What I need is to test against the 6 main categories (IDs 1-6). Each main category has its own sidebar (sidebar1.php … sidebar6.php).

    Being somewhat new to WordPress and PHP, I don’t know how to test for a particular category.

    If you could provide a sample of how to set up the condition it would be greatly appreciated.

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter Storyman

    (@storyman)

    Thanks to an earlier post by tptboy, I was able to piece this together. After getting the parent ID# for the parent it is used to select the sidebar file. There is a corresponding sidebar # for each category.

    Is any of the code I used deprecated?

    $cat_object = $wp_query->get_queried_object();
    $cat_parent = $cat_object->category_parent;
    include (‘sidebar’.$cat_parent.’.php’);

Viewing 1 replies (of 1 total)
  • The topic ‘Need help with PHP code’ is closed to new replies.