Created
January 2, 2017 13:18
-
-
Save dasbairagya/377c4f516efd428a8796d1e2bda4205d to your computer and use it in GitHub Desktop.
get a list of posts from Custom 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 | |
| $terms = get_terms( array( | |
| 'taxonomy' => 'taxonomy_name', | |
| 'hide_empty' => false, | |
| ) ); | |
| //from the above code you will get the term id; | |
| $args = array( | |
| 'post_type' => 'product', | |
| 'post_status' => 'publish', | |
| 'posts_per_page' => -1, | |
| 'tax_query' => array( | |
| array( | |
| 'taxonomy' => 'taxonomy_name', | |
| 'field' => 'id', | |
| 'terms' => '22' | |
| ) | |
| ) | |
| ); | |
| ?> | |
| <ul> | |
| <?php | |
| foreach($args as $arg){ ?> | |
| //html code here | |
| <li><?php echo $arg->name; ?></li> | |
| <?php } ?> | |
| </ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment