Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
Created November 20, 2017 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiemitchell/bad4ba342c387fca551f7ddcef234b7c to your computer and use it in GitHub Desktop.
Save jamiemitchell/bad4ba342c387fca551f7ddcef234b7c to your computer and use it in GitHub Desktop.
Show on parent post on taxonomy archive when using Hierarchical CPT posts
<?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