Support

Account

Home Forums General Issues Different fields on category/sub-category

Solved

Different fields on category/sub-category

  • I’m in the process of creating a custom post type for a site I’m working on. This post type will have a hierarchical custom taxonomy.

    I know I can add custom fields to the taxonomy pages with acf, my question is:
    is there a way to set it up so that child “categories” have different custom fields than parent “categories”?

    Thanks for any help

  • Hi @Hube2

    Currently, this is not possible. However, it is very possible to create your own custom location rule!

    You could create a rule to look at the taxonomy term’s parent and then return true / false depending on the result.

    You can read how to create a custom location rule here:
    http://www.advancedcustomfields.com/resources/tutorials/custom-location-rules/

  • Hi there @Hube2,

    I too have required this functionality today, due to being at work I am unable to test this for a variety of taxonomies although I have used it for shopp-categories.

    Please let me know how you get on with this.

    https://github.com/WazzaJB/ACF-Taxonomy-Depth-Rule

    Wazza

  • Thanks, I’ll give it a whirl and let you know how it goes.

  • @WazzaJB

    Worked a charm, added your code to my custom plugin class for this site. I have not tested it completely, only tested to see if it worked on the parent level so far. Will test the rest as I use it. But after reading the instructions that Elliot linked to and looking at your code I don’t see why it wouldn’t work.

    Thanks a heap, saved me a boatload of time trying to figure it out on my own. Now I have an example to follow 🙂

  • No problem @hube2 glad I could help, I’m sure you’ll be able to tweak it to better suit your needs 🙂

  • Hello

    How you could create a rule valid for all post belonging to a subcategory of a main category?

    I mean, if I have a structure like this:

    – Category 1
    – Sub-category 1-1
    – Post 1-1-1
    – Post 1-1-2
    – Sub-category 1-2
    – Post 1-2-1
    – Post 1-2-2
    – Post 1-2-3

    – Category 2
    – Sub-category 2-1
    – Post 2-1-1
    – Post 2-1-2
    – Sub-category 2-2
    – Post 2-2-1
    – Post 2-2-2
    – Post 2-2-3

    I want the post in category 1 have some fields, and the post of Category 2 given different fields

  • Hi @pablo[email protected],

    Unfortunately this location rule does not incorporate this facility. I believe you would need to create your own location rule to achieve this.

    Many thanks,
    Warren

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Different fields on category/sub-category’ is closed to new replies.