How to query custom post type with 3 custom taxonomies linked to it

I’m new to WordPress but I would like to know how can one get a custom post type linked to 3 custom taxonomies. I have created a custom post type called “product” and created three custom taxonomies and linked them to the product post type. My aim is to make a product have category, brand and type..which are the three custom taxonomies I have created.

Here is my functions.php file. My goal is to come up with something like this where “Ved” is the category name, “Stuv” is the brand name, and “Braskaminer” is the type name of the product and lastly “stuv 16 H”, “Hwam 2630” etc. are the respective products. I will really appreciate if I can get some guidance on how I can use WordPress functions to achieve this.

Related posts

1 comment

  1. When registering a post type, always register your taxonomies using
    the taxonomies argument. If you do not, the taxonomies and post type
    will not be recognized as connected when using filters such as
    parse_query or pre_get_posts. This can lead to unexpected results and
    failures.

    http://codex.wordpress.org/Function_Reference/register_post_type#Taxonomies

    Your argument list for register_post_type needs to include:

    'taxonomy' => array('ct1','ct2','ct3')
    

    Your custom taxonomies have to be registered first.

    Alternately, you can use register_taxonomy_for_object_type.

    register_taxonomy_for_object_type( 'ct1', 'yourcpt' );
    register_taxonomy_for_object_type( 'ct2', 'yourcpt' );
    register_taxonomy_for_object_type( 'ct3', 'yourcpt' );
    

    Again, your custom taxonomies have to be registered first.

Comments are closed.