[resolved] One taxonomy for multiple post types? (4 posts)

  1. HeroicNate
    Posted 6 years ago #

    Is it possible to have post-types share taxonomies?

    For example, I want to make a reviews post type and a news post type. I want there to be a Movie Name taxonomy that will be usable across both post types. Is this possible? As of right now I've only been able to get a taxonomy to work in a single post type.

  2. Russell Heimlich
    Posted 6 years ago #

    Sure. According to the documentation for registering a taxonomy (http://codex.wordpress.org/Function_Reference/register_taxonomy)
    you can use an array for the taxonomy object type

    A name or array of names of the object type(s) for the taxonomy object.

    So your code would look like this:

          array( 'reviews','news' ),
          array( 'hierarchical' => false,
                 'label' => __('Actors', 'series'),
                 'query_var' => 'actor',
                 'rewrite' => array( 'slug' => 'actors' )
  3. HeroicNate
    Posted 6 years ago #

    freakin awesome

  4. jroakes
    Posted 5 years ago #

    So now that we know that multiple post types can share a taxonomy, how would you craft a url to know which post type to display when you select a certain taxonomy tag?

Topic Closed

This topic has been closed to new replies.

About this Topic