Last active
February 12, 2018 03:42
-
-
Save clreed87/75bab3d99d92ee84f08de70095157d72 to your computer and use it in GitHub Desktop.
Remove status post format from main query unless page is the status archive or an admin screen
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 | |
// Do not include the opening php tag. | |
//* Remove status post format from main query unless page is the status archive or an admin screen | |
add_filter( 'pre_get_posts', 'crt_remove_status_format' ); | |
function crt_remove_status_format( $query ) { | |
if ( ! is_tax( 'post_format', 'post-format-status' ) && ! is_search() && ! is_admin() && ! ( defined ( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) ) { | |
$tax_query = array( array( | |
'taxonomy' => 'post_format', | |
'field' => 'slug', | |
'terms' => 'post-format-status', | |
'operator' => 'NOT IN', | |
) ); | |
$query->set( 'tax_query', $tax_query ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment