• Hi! I’m building a portfolio site using custom post type and custom taxonomy that will categorize the portfolio pieces being displayed.

    custom post type : “portfolio”
    registered taxonomy : “categorie” and “client”

    For each portfolio item, I’m displaying thumbnails of related work (same “categorie”) and related work for the same client (taxonomy “client”).

    It have everything working, except I want to add a filter to remove all posts of the same “categorie” that also has the same “client” as the current post.

    Here is the code as is, without the rule to remove all posts from same “client” :

    function ShowRelatedPorfolioElementsbyCategorie() {
    	global $post;
    	$post_type = 'portfolio';
    	$this_post = $post->ID;
    	$terms = get_the_terms( $post->ID, 'categorie' );
    		if ( $terms && ! is_wp_error( $terms ) ) :
    		$categorie_links = array();
    		foreach ( $terms as $term ) {
    		$categorie_links[] = $term->slug;
    		}
    
    		$categorie = join( ", ", $categorie_links );
    		endif;
    
    	if ($term) {
    		$args=array(
    		'showposts' => 3,
    		'categorie' => $categorie,
    		'post_type' => $post_type,
    		'orderby' => rand,
    		'post__not_in' => array($this_post),
    		);
    
    	$my_query = null;
    		$my_query = new WP_Query($args);
    			if( $my_query->have_posts() ) {
    
    			while ($my_query->have_posts()) : $my_query->the_post(); 
    
    			echo '<div class="two columns alpha marginBottom10">';
    			echo'<a href="' . get_permalink() . '">';
    			the_post_thumbnail('featuredImage');
    			echo '</a></div>';
    
    			endwhile;
    			}
    		wp_reset_query();
    		}
    }

    Any ideas?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Term filter for protfolio site’ is closed to new replies.