WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Custom Post Type UI] Use same taxonomy on different post types (13 posts)

  1. adam533
    Member
    Posted 4 years ago #

    I am looking for a way to use the same taxonomy field for two different post types. I am going to be listing tutorials and articles and will want to share the same taxonomy names. I need two different post types though because I am using custom fields to create different meta boxes so the client can easily fill out the needed info.

    For example. If I setup a taxonomy of Subject, I would want to be able to assign a subject of "soccer" to both a the Tutorial and Articles post types.

    Thanks

    http://wordpress.org/extend/plugins/custom-post-type-ui/

  2. tzeldin88
    Member
    Posted 4 years ago #

    I'd love to know the answer to this too. Do we need to actually create DIFFERENT taxonomies, one for each post-type, like "subject-tutorials" and "subject-articles" (and the Label for each can be "Subject"). We would want the same Terms in each Taxonomy, but we'd have to manage that manually.. they would not actually be connected in the database at all. Right?

  3. tzeldin88
    Member
    Posted 4 years ago #

    I think we actually can SHARE TAXONOMIES among different custom content types. When we register a Taxonomy, we specify a single content type. But when we register a Custom Content Type, we can specify various Taxonomies that it uses (http://codex.wordpress.org/Function_Reference/register_post_type ).

    I had been using a plugin to create my custom content type (Custom Post Type UI), so I didn’t realize there are more things we can specify by doing it manually in functions.php.

    Now my custom taxonomy “Color” appears under both of my content types (Articles, Reports). And the Count for each term includes both content types.

    Thanks to Chris Coyier & Jeff Starr of Digging into WordPress (http://digwp.com/2010/05/guide-new-features-wordpress-3/) for pointing me in the right direction.

  4. adam533
    Member
    Posted 4 years ago #

    Great - thank you very much. Hopefully this is something that will be supported with the Custom Post Type UI plugin soon, but for now I will work on the beta version using the functions.php and coding myself.

  5. MichaelH
    Member
    Posted 4 years ago #

    You can also register a taxonomy to multiple post types with something like this where genre is registered to book, post, and page:

    register_taxonomy('genre',array('book','post','page'), array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'genre' ),
      ));
  6. adam533
    Member
    Posted 4 years ago #

    Thanks MichaelH - that is a help also.

  7. thecorkboard
    Member
    Posted 4 years ago #

    Thanks everyone - this was exactly what I was looking for.

    ~Kyle~

  8. Od3n
    Member
    Posted 4 years ago #

    my taxanomies doesnt show up in custom post list. any idea?

  9. Od3n
    Member
    Posted 4 years ago #

    nvmnd. get it done already.

  10. Decio
    Member
    Posted 4 years ago #

    How about sharing Tags with the default post-type? I included tags in my custom taxonomies for a new post-type but it seems to be independent from the default tags.

    Could it be shared also?

  11. Od3n
    Member
    Posted 4 years ago #

    @Decio

    try add this to your registered taxonomy.

    'taxonomies' => array('category','post_tag')

    it will use default category and tags taxonomies.

  12. Decio
    Member
    Posted 4 years ago #

    @od3n

    Tks! After i read this article by Otto: http://ottopress.com/2010/wordpress-3-0-and-custom-post-types/
    I decided custom post-type isn´t for me.

  13. Leo Plaw
    Member
    Posted 3 years ago #

    $args = array(
    ‘labels’ => $labels,
    ‘singular_label’ => __(‘Video’),
    ‘public’ => true,

    // … all of the others…

    ‘taxonomies’ => array( ‘category’,'post_tag’) // add standard post categories and post tags

    );

    register_post_type( ‘videos’ , $args );
    }

Topic Closed

This topic has been closed to new replies.

About this Topic