Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link
added 36 characters in body
Source Link
Chip Bennett
  • 55.1k
  • 8
  • 90
  • 170
// Post Formats
$post_formats_array = array(
    post'post-format-asideaside',
    post'post-format-audioaudio',
    post'post-format-chatchat',
    post'post-format-gallerygallery',
    post'post-format-imageimage',
    post'post-format-linklink',
    post'post-format-statusstatus',
    post'post-format-quotequote',
    post'post-format-videovideo'
);
// Custom query args
$standard_posts_query_args = array(    
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            // Use array defined above,
            // or try omitting 'terms' entirely
            'terms' => $post_formats_array,             
            'operator' => 'NOT IN'
        )
    )
);
// Custom query
$standard_posts = new WP_Query( $standard_posts_query_args );

// Custom query loop
if ( $standard_posts->have_posts() ) : while ( $standard_posts->have_posts() ) : $standard_posts->the_post();
    // Loop markup here
endwhile; endif;
function wpse129372_filter_posts_archive( $query ) {
    if ( $query->is_main_query && $query->is_archive() ) {
        $post_formats_array = array(
            post'post-format-asideaside',
            post'post-format-audioaudio',
            post'post-format-chatchat',
            post'post-format-gallerygallery',
            post'post-format-imageimage',
            post'post-format-linklink',
            post'post-format-statusstatus',
            post'post-format-quotequote',
            post'post-format-videovideo'
        );
        $tax_query = array(
            array(
                'taxonomy' => 'post_format',
                'field' => 'slug',
                // Use array defined above,
                // or try omitting 'terms' entirely
                'terms' => $post_formats_array,             
                'operator' => 'NOT IN'
            )
        );
        $query->set( 'tax_query', $tax_query );
    }
}
add_action( 'pre_get_posts', 'wpse129372_filter_posts_archive' );
// Post Formats
$post_formats_array = array(
    post-format-aside,
    post-format-audio,
    post-format-chat,
    post-format-gallery,
    post-format-image,
    post-format-link,
    post-format-status,
    post-format-quote,
    post-format-video
);
// Custom query args
$standard_posts_query_args = array(    
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            // Use array defined above,
            // or try omitting 'terms' entirely
            'terms' => $post_formats_array,             
            'operator' => 'NOT IN'
        )
    )
);
// Custom query
$standard_posts = new WP_Query( $standard_posts_query_args );

// Custom query loop
if ( $standard_posts->have_posts() ) : while ( $standard_posts->have_posts() ) : $standard_posts->the_post();
    // Loop markup here
endwhile; endif;
function wpse129372_filter_posts_archive( $query ) {
    if ( $query->is_main_query && $query->is_archive() ) {
        $post_formats_array = array(
            post-format-aside,
            post-format-audio,
            post-format-chat,
            post-format-gallery,
            post-format-image,
            post-format-link,
            post-format-status,
            post-format-quote,
            post-format-video
        );
        $tax_query = array(
            array(
                'taxonomy' => 'post_format',
                'field' => 'slug',
                // Use array defined above,
                // or try omitting 'terms' entirely
                'terms' => $post_formats_array,             
                'operator' => 'NOT IN'
            )
        );
        $query->set( 'tax_query', $tax_query );
    }
}
add_action( 'pre_get_posts', 'wpse129372_filter_posts_archive' );
// Post Formats
$post_formats_array = array(
    'post-format-aside',
    'post-format-audio',
    'post-format-chat',
    'post-format-gallery',
    'post-format-image',
    'post-format-link',
    'post-format-status',
    'post-format-quote',
    'post-format-video'
);
// Custom query args
$standard_posts_query_args = array(    
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            // Use array defined above,
            // or try omitting 'terms' entirely
            'terms' => $post_formats_array,             
            'operator' => 'NOT IN'
        )
    )
);
// Custom query
$standard_posts = new WP_Query( $standard_posts_query_args );

// Custom query loop
if ( $standard_posts->have_posts() ) : while ( $standard_posts->have_posts() ) : $standard_posts->the_post();
    // Loop markup here
endwhile; endif;
function wpse129372_filter_posts_archive( $query ) {
    if ( $query->is_main_query && $query->is_archive() ) {
        $post_formats_array = array(
            'post-format-aside',
            'post-format-audio',
            'post-format-chat',
            'post-format-gallery',
            'post-format-image',
            'post-format-link',
            'post-format-status',
            'post-format-quote',
            'post-format-video'
        );
        $tax_query = array(
            array(
                'taxonomy' => 'post_format',
                'field' => 'slug',
                // Use array defined above,
                // or try omitting 'terms' entirely
                'terms' => $post_formats_array,             
                'operator' => 'NOT IN'
            )
        );
        $query->set( 'tax_query', $tax_query );
    }
}
add_action( 'pre_get_posts', 'wpse129372_filter_posts_archive' );
added 1368 characters in body
Source Link
Chip Bennett
  • 55.1k
  • 8
  • 90
  • 170

Edit

Note: you can use the same technique for a custom page template, with a custom loop via new WP_Query():

// Post Formats
$post_formats_array = array(
    post-format-aside,
    post-format-audio,
    post-format-chat,
    post-format-gallery,
    post-format-image,
    post-format-link,
    post-format-status,
    post-format-quote,
    post-format-video
);
// Custom query args
$standard_posts_query_args = array(    
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            // Use array defined above,
            // or try omitting 'terms' entirely
            'terms' => $post_formats_array,             
            'operator' => 'NOT IN'
        )
    )
);
// Custom query
$standard_posts = new WP_Query( $standard_posts_query_args );

// Custom query loop
if ( $standard_posts->have_posts() ) : while ( $standard_posts->have_posts() ) : $standard_posts->the_post();
    // Loop markup here
endwhile; endif;

Pagination

For pagination, please refer to this Question/Answer.

Original Answer

Edit

Note: you can use the same technique for a custom page template, with a custom loop via new WP_Query():

// Post Formats
$post_formats_array = array(
    post-format-aside,
    post-format-audio,
    post-format-chat,
    post-format-gallery,
    post-format-image,
    post-format-link,
    post-format-status,
    post-format-quote,
    post-format-video
);
// Custom query args
$standard_posts_query_args = array(    
    'tax_query' => array(
        array(
            'taxonomy' => 'post_format',
            'field' => 'slug',
            // Use array defined above,
            // or try omitting 'terms' entirely
            'terms' => $post_formats_array,             
            'operator' => 'NOT IN'
        )
    )
);
// Custom query
$standard_posts = new WP_Query( $standard_posts_query_args );

// Custom query loop
if ( $standard_posts->have_posts() ) : while ( $standard_posts->have_posts() ) : $standard_posts->the_post();
    // Loop markup here
endwhile; endif;

Pagination

For pagination, please refer to this Question/Answer.

Original Answer

Source Link
Chip Bennett
  • 55.1k
  • 8
  • 90
  • 170
Loading