WordPress.org

Ready to get started?Download WordPress

Forums

SuperCPT
[resolved] Struggling with hierarchical taxonomies (3 posts)

  1. mattyd247
    Member
    Posted 1 year 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.

    http://wordpress.org/extend/plugins/super-cpt/

  2. Matthew Boynes
    Member
    Plugin Author

    Posted 1 year 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
    Member
    Posted 1 year 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

About this Topic

Tags

No tags yet.