i duplicated a portfolio column page template ... On this page I want to show only one category , instead of all categories... I tried a lot, but couldn't get it worked...
this is the original code to show all categories:
<div class="container">
<ul id="ublportfolio" class="grid cs-style-3">
<?php
query_posts( array( 'post_type' => 'ublalfieportfolio', 'posts_per_page' => -1) );
if ( have_posts() ) : while ( have_posts() ) : the_post();
global $post;
$terms = get_the_terms($post->ID, 'ublalfieportfolio-categories');
$taxclassadd = '';
foreach($terms as $t){$taxclassadd .= ' ' . $t->slug;}
$taxclass = 'thisportfolioitem twocol' . $taxclassadd; $str= ltrim ($taxclassadd,' ');
?>
<li <?php post_class($taxclass); ?> id="post-<?php the_ID(); ?>" data-category="<?php echo $str; ?>">
<figure>
<?php if(has_post_thumbnail()) {
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false);
if($thumbnail['1'] > 1024){$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large', false);} ?>
<img src="<?php echo $thumbnail['0']; ?>" alt="<?php the_title(); ?>">
<?php } ?>
<figcaption>
<h3><?php the_title(); ?></h3>
<span><?php if($post->post_excerpt){$getcontent = get_the_excerpt();echo $getcontent;} ?></span>
<a href="<?php the_permalink(); ?>"><?php _e('View Item','ublalfie'); ?></a>
</figcaption>
</figure>
</li>
<?php endwhile; endif; ?>
</ul>
</div>
for example I only want to show : the category-slug = "parketten" and ID = 3
I tried this:
<?php
query_posts( array( 'post_type' => 'ublalfieportfolio', 'category_name' => 'terrassen', 'posts_per_page' => -1) );
if ( have_posts() ) : while ( have_posts() ) : the_post();
global $post;
$terms = get_the_terms($post->ID, 'parketten');
$taxclassadd = '';
foreach($terms as $t){$taxclassadd .= ' ' . $t->slug;}
$taxclass = 'span4 portfolioitem text-center' . $taxclassadd; $str= ltrim ($taxclassadd,' ');
?>
result : shows nothing
<?php
query_posts( array( 'post_type' => 'ublalfieportfolio', 'category' => array(3), 'posts_per_page' => -1) );
if ( have_posts() ) : while ( have_posts() ) : the_post();
global $post;
$terms = get_the_terms($post->ID, 'parketten');
$taxclassadd = '';
foreach($terms as $t){$taxclassadd .= ' ' . $t->slug;}
$taxclass = 'span4 portfolioitem text-center' . $taxclassadd; $str= ltrim ($taxclassadd,' ');
?>
result: shows all categories..
Can someone please give me a solution... thank you very much