Created
May 2, 2020 13:53
-
-
Save vfontjr/214ea5b35a42909452bed056201c1e56 to your computer and use it in GitHub Desktop.
Source code for https://victorfont.com/filter-wordpress-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