WordPress.org

Support

Support » Plugins and Hacks » [Resolved] One taxonomy for multiple post types?

[Resolved] One taxonomy for multiple post types?

  • 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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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:

    register_taxonomy(
          'movie_name',
          array( 'reviews','news' ),
          array( 'hierarchical' => false,
                 'label' => __('Actors', 'series'),
                 'query_var' => 'actor',
                 'rewrite' => array( 'slug' => 'actors' )
          )
       );

    freakin awesome

    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] One taxonomy for multiple post types?’ is closed to new replies.
Skip to toolbar