Created
April 5, 2018 20:10
-
-
Save Inzman/a512f4570f192835827a7f7ebb3bc8a9 to your computer and use it in GitHub Desktop.
Posts by category
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
| $tax = 'music'; | |
| $oterm = 'pop'; | |
| $term = get_term_by('slug', $oterm, $tax); | |
| $termChildren = get_term_children($term->term_id, $tax); | |
| $wp_query = new WP_Query(); | |
| $wp_query->query( | |
| array( | |
| 'posts_per_page' => '5', | |
| 'tax_query' => array( | |
| array( | |
| 'taxonomy' => $tax, | |
| 'field' => 'slug', | |
| 'terms' => $oterm | |
| ), | |
| array( | |
| 'taxonomy' => $tax, | |
| 'field' => 'id', | |
| 'terms' => $termChildren, | |
| 'operator' => 'NOT IN' | |
| ) | |
| ) | |
| ) | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment