WordPress.org

Ready to get started?Download WordPress

Forums

register_taxonomy() (6 posts)

  1. d910qf
    Member
    Posted 6 years ago #

    Has anyone used this function?

    I am interested in creating a new taxonomy (extra to tags and categories) and can't seem to find out how to do this or if it is possible.

    For example I would like to keep the tags taxonomy as a user inputted field and then create an autotags taxonomy that is entirely seperate (and is accessable at http://www.example.com/autotags).

    Chris.

  2. d910qf
    Member
    Posted 5 years ago #

    This is actually pretty simple once you know how...

    Just use register_taxonomy( 'people', 'post', array('rewrite' => array('slug'=>'people')));

    In your templates functions.php to make the template aware of the taxonomy. Then you can use all the taxonomy functions to add/remove/associate posts to terms in the taxonomy (you'll need to look at wp-includes/taxonomy.php.

    Then if you want to use url variables to do something you have the url http://www.blog.com/people/person and can access the 'person' by using

    get_query_var('people').

    This allows you to have any number of http://www.blog.com/taxonomy/term type situations.

    Still looking at how to use similar functionality of tags (tag+tag etc) without rewriting all the functions. Still think this should be in wordpress by default - drupal does it really well.

  3. Konpyuuta
    Member
    Posted 5 years ago #

    Hello,

    I was actively searching for a solution to my case, and finally heard about "Taxonomy" thing.
    As I'm not a programmer ... but with some knowledge about HTML (maybe it would help -.-°), could be please help in how to use those?

    Your example of "( 'X', 'post', array('rewrite' => array('slug'=>'X')));" and "get_query_var('X')" insn't that clear for me.
    Is there anyway you give a clearer example? Or maybe a little tutorial?

    That would be awesome, thank you in advance.
    Sincerely.

  4. MartyThornley
    Member
    Posted 5 years ago #

  5. Justin Tadlock
    Member
    Posted 5 years ago #

    @MartyThornley - Yep, that should help.

    Here's my other article on this:
    http://justintadlock.com/archives/2009/06/04/using-custom-taxonomies-to-create-a-movie-database

  6. MartyThornley
    Member
    Posted 5 years ago #

    These both sounded great, but it isn't working. I have copied them exactly into my functions.php, but the new taxonomies don't show up anywhere.

Topic Closed

This topic has been closed to new replies.

About this Topic