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 am using this code to get all the custom post types shown on the startpage:

    add_action('pre_get_posts','wpse57309_alter_front_page_query');
function wpse57309_alter_front_page_query( $query ){
     if( $query->is_main_query() && is_front_page() ){
         if( !$query->get('post_type') ){
             //post type is not set, the default will be an array of them:
             $query->set('post_type',array( 'news', 'events', 'tv'));



         }
     }
}

But now I want only custom posts with a custom taxonomy "superevent=true".

How can I build this!?

Thank you!

AD

share|improve this question
add comment

1 Answer

For taxonomy superevent and term true:

add_action('pre_get_posts','wpse57309_alter_front_page_query');
function wpse57309_alter_front_page_query( $query ){
     if( $query->is_main_query() && is_front_page() ){
         if( !$query->get('post_type') ){
            //post type is not set, the default will be an array of them:
            $query->set( 'post_type', array( 'news', 'events', 'tv' ) );
            $query->set( 'superevent', 'true' );
         }
     }
}
share|improve this answer
    
great! Thank you! –  ad2003 Sep 6 '12 at 17:21
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.