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 created a custom post type in my function.php of the theme and some a taxonomy for them. I added 2 categories in my taxonomy (first, second) and added some post in my new custom post.

I want to make a loop that will select from my custom posts only the ones in the first category (Taxonomy)

Or I want a archive that will display all my custom posts, but separated by the taxonomy like First category: one post, another post Second Category: this post, next post

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Before the loop starts use query_posts. Available parameters are here. Something like this:

global $wp_query;
query_posts( array( 
                    'post_type' => 'mycustomname', 
                    'tax_query' => array( 
                                           'relation' => 'AND', 
                                           array( 
                                                  'taxonomy' => 'mytaxonomyname', 
                                                  'field' => 'slug',
                                                  'terms' => array( 
                                                                    'myterm1slug',
                                                                    'myterm2slug' 
                                                                   ) 
                                                ) 
                                        ) 
                  ) 
);    
share|improve this answer
add comment

I guess these will help you: http://codex.wordpress.org/Post_Types#Archive_template and Custom Taxonomy Displays Say you have a taxonomy named 'fiction'. Then your template will be taxonomy-fiction.php. In general, taxonomy-<taxonomy name>.php is the way to go!

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.