• Resolved niska

    (@niska)


    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?

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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' ),
      ));
    Thread Starter niska

    (@niska)

    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

    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.

    Thread Starter niska

    (@niska)

    I understand. Thank you for your help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom taxonomies and relations’ is closed to new replies.