treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Custom Taxonomies and Post Types

  • I have 1 custom taxonomy assigned to 3 custom post types. Then I have 4 categories in my custom taxonomy. How can I make each category in my custom taxonomy a page on my website that displays the posts from each post type in that category of my custom taxonomy? I hope that makes sense.

    Thanks you.
  • Click on 'Appearance' in the menu. A list of items should drop down such as "Themes", etc. One of these is named "Menu". Click on menu, and you should see your custom post type on the left somewhere. Click the "show all" tab and you should see your 4 categories. Tick them and click "Add to menu". Save the menu.

    (I'm assuming your theme supports the wordpress 3 menu)

    Is this what you meant?
  • No, I'm sorry for not being clear. I want to create a template php file that applies to all of my taxonomy categories. So my questions are:

    1. How can I create three loops that go through each post type?

    2. How do I assign that file to all of my categories in my taxanomy? (I would assume through funtions.php somehow???)

    3. I want to create it like so:

    taxanomy-name.php:

    if( taxonomy root - mydomain.com/custom-taxonomy/ ) {
    show category link buttons
    } elseif ( taxonomy category - mydomain.com/custom-taxonomy/tax-category-[01,02,03,04,05] ) {
    loop for first post type
    loop for second post type
    loop for third post type
    }

    Does that make sense?

    Thanks.
  • I would explode() the forwardslashes, and get the last (or wherever the taxonomy name is in the url) array, create a variable and do something like:
    if($exploded_tax == 'tax'){
    // insert special single page code
    }
    else{
    // insert code for all single pages
    }

    (within the single.php)
    http://php.net/manual/en/function.explode.php
    http://php.net/manual/en/language.types.array.php