Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have no idea how to do this and really need your help please …

First I created a custom-post-template called "wr_event" - then I added a custom taxonomy (like categories) to this post-template!

register_taxonomy(
    'Type of event',
    'wr_event',
    array(
        'taxonomy' => 'event_type',
        'label' => 'Types',
        'singular_label' => 'Type',
        'hierarchical' => true,
        'rewrite' => true)
);

I did all that in my functions.php file. The "types" I created in my taxonomy in the wp-backend right now are "Lectures", "Workshops", "Festivals".

If I create a post (event) and assign it to a "category" (taxonomy) I get this url localhost.com/lectures/my-post-title and the single-wr_event.php template is used.

This is already a big step towards what I finally want.

What I don't know is how I can now kind of create pages for my taxonomies like it automatically works for posts and categories?

e.g. I said I have this right now: localhost.com/lectures/my-post-title

but when I just enter localhost.com/lectures/ I want all the posts assigned to this taxonomie listed. And I'd like to add a navigation in my header that lists all taxonomies I created just like 'wp_list_categories'.

Any ideas on how to this?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You can create the file taxonomy-event_type.php. That will be used when you use the url /?event_type=lectures or /event_type/lectures.

You can use wp_list_categories by adding 'taxonomy' => 'event_type' to the arguments (see http://codex.wordpress.org/Template_Tags/wp_list_categories#Display_Terms_in_a_custom_taxonomy)

share|improve this answer
    
Thank you very much! This worked just fine! Only last question I have is how I can filter the posts by term on each "category". So right now just like you posted the taxonomy-event_type.php template is used for my taxonomy. When I call /event_type/lectures I use a simple query $loop = new WP_Query( $args ); to get all posts. However on the lectures-page I only want to see/filter all lectures from this taxonomy. Any idea how I can filter this within the same taxonomy-event_type.php template? Thank you very much! –  mathiregister Apr 10 '12 at 14:22
1  
Not sure I understand correctly but you should let wordpress do the query. When you call /event_type/lectures wordpress has already filtered the posts for you and you just have to output them. (for example: while ( have_posts() ) : the_post(); the_title(); endwhile; ) –  offroff Apr 10 '12 at 18:37
    
Thank you, didn't know wordpress handles this automatically! –  mathiregister Apr 10 '12 at 20:14
add comment
   function wp_list_tax_terms($tax = 'category',$order,$hide_empty = FALSE){
    $terms = get_terms( $tax, array(
        'orderby'    => $order,
        'hide_empty' => $hide_empty
     ));
     if ( $count > 0 ){
     echo '<ul>';
     foreach ( $terms as $term ) {
       echo '<li><a href="'.$term->name.'">'.$term->name.'</a></li>';   
     }
     echo '</ul>';
  }    
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.