Created
May 31, 2013 23:31
-
-
Save whyisjake/5688636 to your computer and use it in GitHub Desktop.
Looking for a way to filter posts out of the main loop in the admin if they have a certain taxonomy term associated with them.
This file contains hidden or 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 | |
/** | |
* Hide Maker Faire applications from past faires | |
* | |
* In the past, CS had a method for only selecting the current | |
* faire for applications. We want to do the same here, and prevent | |
* all applications from showing up in the edit screen. | |
* | |
* @global $query | |
* | |
*/ | |
function mf_hide_faires( $query ) { | |
if ( is_admin() && $query->is_main_query() && 'mf_form' == get_post_type() ) { | |
//$query->set( 'faire', '-328' ); | |
$tax_query = array( | |
array( | |
'taxonomy' => 'faire', | |
'field' => 'ID', | |
'terms' => 328, | |
'operator' => 'NOT IN', | |
) | |
); | |
$query->set( 'tax_query', $tax_query ); | |
return $query; | |
} | |
} | |
add_action( 'pre_get_posts', 'mf_hide_faires' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment