wordpress: display custom post type of a category by making a function so that you can call this function on a template and show related post type only.
I am also using a limit so it will be easy to get the variable in quantity.
Here ‘masonry-portfolio-categories’ is a taxonomy and ‘masonry-portfolio’ is a post type.
Pass the $ppp for postperpage and $cat for category slug.
{
?>
<div id=”content-home-pf”>
<?php
$all_terms = get_terms( ‘masonry-portfolio-categories’, array(‘hide_empty’ => 0 ) );
$count = 1;
$args = array(
‘post_type’ => ‘masonry-portfolio’,
‘posts_per_page’ => $ppp,
‘masonry-portfolio-categories’ => $cat
);
query_posts($args);
if (have_posts()) :echo “<h3>Related Projects</h3><br/>”; while (have_posts()) : the_post();
$terms = get_the_terms( get_the_ID(), ‘masonry-portfolio-categories’ );
$featured = get_post_meta(get_the_ID(), ‘pt_featured’, TRUE);
$imgurl = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?>
<div class=”wrapper-home-pf animated” style=”width: 33.3%;”>
<?php if ( has_post_thumbnail() ) : ?><?php the_post_thumbnail(‘large’); ?>
<div class=”show-button-wrap”>
<a href=”<?php the_permalink(); ?>”><i class=”icon-link captionicons”></i></a>
<a href=”<?php echo $imgurl; ?>” title=”<?php the_title(); ?>”><i class=”icon-zoom-in captionicons”></i></a>
</div>
<?php endif; ?>
</div>
<?php $count++; endwhile; endif; ?>
</div>
<?php
}