Created
May 23, 2021 21:08
-
-
Save frankyonnetti/3b8e72f30c322bf5595ebf4b14a4f84a to your computer and use it in GitHub Desktop.
WordPress - CPT parent only based on taxonomy #wordpress #taxonomy
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 | |
| // 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