Created
November 20, 2017 10:31
-
-
Save jamiemitchell/bad4ba342c387fca551f7ddcef234b7c to your computer and use it in GitHub Desktop.
Show on parent post on taxonomy archive when using Hierarchical CPT posts
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 | |
add_action( 'pre_get_posts', 'jmd_taxonomy_parents_only' ); | |
function jmd_taxonomy_parents_only( $query ) { | |
if ( ! is_admin() && $query->is_tax( 'your_tax_term' ) ) { | |
$query->set( 'post_parent', 0 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment