Skip to content

Instantly share code, notes, and snippets.

@dasbairagya
Created January 2, 2017 13:18
Show Gist options
  • Select an option

  • Save dasbairagya/377c4f516efd428a8796d1e2bda4205d to your computer and use it in GitHub Desktop.

Select an option

Save dasbairagya/377c4f516efd428a8796d1e2bda4205d to your computer and use it in GitHub Desktop.
get a list of posts from Custom Taxonomy
<?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