[resolved] Struggling with hierarchical taxonomies (3 posts)

  1. mattyd247
    Posted 3 years ago #

    Hi, Great plugin but I'm struggling to work out what parameters I would have to add to the Super_Custom_Taxonomy() function in order to make them hierarchical?

    This is my code so far: $tax_materials = new Super_Custom_Taxonomy( 'material');

    Any help would be really appreciated.


  2. Matthew Boynes
    Plugin Author

    Posted 3 years ago #

    Hi mattyd247,
    Thanks for checking out the plugin!

    There are a couple of ways to set the taxonomy as hierarchical. The most "core" is that you can pass that as one of the array args when setting up the taxonomy, just like you would in register_taxonomy. Since this attribute is so likely to change, I made a special parameter for it in the class construct.

    $tax = new Super_Custom_Taxonomy( $name, $singular = false, $plural = false, $acts_like = false, $register = array() )

    $acts_like allows you to say this acts like a "tag" or a "category". Since non-hierarchical (tag) is the default, you'd probably only ever pass it "category" unless you wanted to be explicit. Incidentally, you can even abbreviate it to "cat".

    So your material construct would become,
    $tax_materials = new Super_Custom_Taxonomy( 'material', 'Material', 'Materials', 'category' );

    You can find the full documentation on this class here: https://github.com/mboynes/super-cpt/wiki/Super_Custom_Taxonomy-Reference

  3. mattyd247
    Posted 3 years ago #

    Thanks Matthew.... that's exactly what I was looking for and that works great.

    Keep up the good work

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • SuperCPT
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.