Support » Fixing WordPress » Select a parent post category, automatically select all subcategories?

  • Toni


    I’m trying to figure out how to make it so that when you select a parent post category in a new post, all of the subcategories will be automatically selected as well.

    Example: If the parent category is Fruit, and the subcategories include the names of different types of fruit, when I write a post about the much broader category of Fruit and select “Fruit” as my category, all of the individual types of fruit that have been named as categories within the Fruit category will be selected too… kind of like making the Fruit category become a “select all subcategories” button.

    I am using WordPress version 3.8 and a Twenty Twelve child theme.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can achieve this well simply by adding the main cat to all related posts.

    So a post about the fruit kiwi would use two categories ‘fruit’ and ‘kiwi’.

    Two categories will then be output to click on.

    Because each post now is actually in that cat, the default cat archive page:


    will output all the posts.

    You can filter your posts by category and then easily add another category.

    You do still then have usable category archives for ‘kiwi’ or other category.

    And, both of these two url’s will be the same list of posts assuming no category grand-children


    That is what to do without doing some coding. With some coding, you can create a specific category template for this category and in it use in_category and not is_category.



    Thanks for your help. 🙂

    I was actually hoping that there would be a way that I could click on the parent category (ie. Fruit) and have all of the subcategories (ie. Kiwi, Apple, Peach, etc.) automatically selected as well.

    The hope is that this will save time, especially when some categories might have 30 or more subcategories… click one button and all subcategories are selected.

    While it’s useful to be able to click on the parent category and see all posts that have been added to subcategories, I’d like to be able to make the process of writing posts a little easier as well.



    Oh – to be a little clearer: my website’s post readers are only able to see specific categories. While labelling a post with a parent category is useful for me, it means that those who can only see specific subcategories are missing out on some information that is relevant to them.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Select a parent post category, automatically select all subcategories?’ is closed to new replies.