Last active
December 14, 2018 09:22
-
-
Save vfontjr/9836af69d6bc2e01926c9b7503d0309f to your computer and use it in GitHub Desktop.
Filter wp_query by post format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function filter_video_format_posts($query) { | |
/* change 999 to the page id for your archive page */ | |
if ( !is_page ('999') ) | |
return $query; | |
$taxquery = array( | |
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