WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom taxonomies and relations (5 posts)

  1. niska
    Member
    Posted 4 years ago #

    Is it possible to create a relation between a custom taxonomy and a regular post?

    Let's say that my post is about a movie that I have defined as a custom taxonomy. How do i make such a relation in WP 3.0?

  2. MichaelH
    Member
    Posted 4 years ago #

    Use Function_Reference/register_taxonomy to register your taxonomy to a post...example here registers taxonomy to book, post, page

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

    Thank you for your help. I'm registering the book taxonomy to a post like this:

    register_taxonomy('book',array('post'), array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'genre' ),
      ));

    Could you also explain how to

    1) choose which book (or books, if WP can handle several relations) that should be connected to the post? Let's say that I have 5000 books. Can I search by title?

    2) display the information about a specific book (or several books, if possible) taxonomy when I'm looking at a post?

    Thanks

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    1. Give the post a term belonging to the taxonomy.
    2. Not sure i follow what you mean.

    Taxonomies are just like tags and categories, categories would be an example of a hierarchal taxonomy and post tags are a non-hierarchal example.

    So for your books taxonomy, as you would with categories, you need to create terms for that taxonomy.

  5. niska
    Member
    Posted 4 years ago #

    I understand. Thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic