OK, so I'm working with a template (I have contacted the developer and they were of no help, so I'm modifying the template page as needed). The template displays portfolio items, using the following code:
<div class="container filter-portfolio clearfix">
<ul id="portfolio" class="clearfix">
<?php
$type = 'portfolio';
$args=array( 'post_type' => $type, 'posts_per_page' => -1 );
query_posts( $args );
if (have_posts()) : while (have_posts()) : the_post();
$terms = get_the_terms( $post->ID, 'portfolio_categories' ); ?>
if (has_post_thumbnail()) {
$thumb = get_post_thumbnail_id();
$thumb_w = '460';
$thumb_h = '272';
$image_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
$image_url = $image_src [0];
$attachment_url = wp_get_attachment_url($thumb, 'full');
$image = aq_resize($attachment_url, $thumb_w, $thumb_h, true);
}
$thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'grid-thumb');
foreach ( $terms as $term ) {
$cats[0] = $term->name;
$catname = join($cats);
$catname = preg_replace('/\s/', '', $catname);
}
$title= get_the_title();
$title= explode(' ',$title);
$title[0]= '<span class="bold">'.$title[0].'</span>';
$title= implode(' ',$title);
?>
<!-- PORTFOLIO ITEM -->
<li data-id="id-<?php echo $post->ID; ?>" data-type="<?php
$terms = get_the_term_list( $post->ID, 'portfolio_categories','',' , ','' );
$terms = preg_replace('/\s/','', $terms);
$terms = strip_tags( $terms );
$terms = preg_replace('/[\s,\-!]/',' ', $terms);
echo $terms;
?>" class="four columns m-bot-25">
<div class="content-container-white">
<div class="view view-first">
<img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" />
<div class="mask">
<h2><?php echo $title; ?></h2>
<a href="<?php echo $attachment_url; ?>" class="lightbox zoom info"></a>
<a href="<?php the_permalink(); ?>" class="link info"></a>
</div>
</div>
<div class="lw-item-caption-container">
<a class="a-invert" href="<?php the_permalink(); ?>" ><?php echo $title; ?></a>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
</div>
Basically, I need to only display posts that match a certain slug, which can be retrieved off $terms. However, when I try the following code modification:
if( $terms->slug != 'product-gallery' ) continue;
placed after the $terms = get_the_terms(...) line, it would seem that The Loop is broken, and no posts are displayed at all on the page. It's important that I can filter the posts, and by slug, as I can't modify the theme very much, and the client needs to be able to add/remove posts by categories for which there are slugs.
Disclaimer: I am new to the WP environment, php, and mysql. However, I am a quick learned and I have plenty of coding experience in C++, Java, Perl, etc. I'm just new to web development.
What am I missing or doing wrong for my goal?
Thanks