Skip to content

Instantly share code, notes, and snippets.

@clreed87
Last active February 12, 2018 03:42
Show Gist options
  • Save clreed87/75bab3d99d92ee84f08de70095157d72 to your computer and use it in GitHub Desktop.
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
<?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