Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save frankyonnetti/3b8e72f30c322bf5595ebf4b14a4f84a to your computer and use it in GitHub Desktop.

Select an option

Save frankyonnetti/3b8e72f30c322bf5595ebf4b14a4f84a to your computer and use it in GitHub Desktop.
WordPress - CPT parent only based on taxonomy #wordpress #taxonomy
<?php
// https://developer.wordpress.org/reference/classes/wp_query
$args = array(
'post_type' => 'dan_health_resources',
'post_parent' => 0,
'orderby' => 'menu_order',
'tax_query' => array(
array (
'taxonomy' => 'dan_health_resource_types',
'field' => 'slug',
'terms' => 'smart-guides',
)
),
);
$loop = new WP_Query($args); ?>
<ul>
<?php while($loop->have_posts()): $loop->the_post(); ?>
<li>
<?php the_title(); ?>
</li>
<?php endwhile; ?>
</ul>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment