Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Filter wp_query by post format
function filter_video_format_posts($query) {
/* change 999 to the page id for your archive page */
if ( !is_page ('999') )
return $query;
$taxquery = array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-video' ),
$query->set( 'tax_query', $taxquery );
add_action( 'pre_get_posts', 'filter_video_format_posts' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment