Created
August 3, 2015 11:18
-
-
Save saxap/765ad67014f4e3cb9a19 to your computer and use it in GitHub Desktop.
exclude children posts from parent taxonomy term page
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
function exclude_children($wp_query) { | |
if (isset($wp_query->query_vars['tax_name'])) { | |
$wp_query->set('tax_query', array(array( | |
'taxonomy' => 'tax_name', | |
'field' => 'slug', | |
'terms' => $wp_query->query_vars['tax_name'], | |
'include_children' => false | |
))); | |
} | |
} | |
add_filter('pre_get_posts', 'exclude_children'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment