• Hi there,

    First Post here please be gentle :o)
    Ok i have problem trying to link data on my site, i have had it working using the Global Category taxonomy but id prefer to use a custom one. The code below worked until i started to use a the custom taxonomy and i have tried to find the correct way of doing this for the last two days with no luck. Basically i have a Custom Post type ‘Condition’ and i want to display all the Custom Post Type ‘Testimonial’ that have the same Custom Taxonomy ‘medical_terms’ any help or pointer much appreciated.

    my code that worked using Categories:

    $categories = get_the_category($post->ID);
    	if ($categories) {
    		$category_ids = array();
    		foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
    
    		$args=array(
    			'category__in' => $category_ids,
    			'post__not_in' => array($post->ID),
    			'showposts'=>5, // Number of related posts that will be shown.
    			'caller_get_posts'=>1,
    			'post_type' => 'testimonial'
    		);
    		$my_query = new wp_query($args);
    
    		if( $my_query->have_posts() ) {
    
    			echo '<h3>Who we have helped</h3><ul class="nb">';
    			while ($my_query->have_posts()) {
    				$my_query->the_post();
    			?>
    			<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    
    			<?php
    			}
    			echo '</ul>';
    		}
    	}

    Regards

    Mick

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Return Custom Post Type from a Custom Post using a Custom Taxonomy’ is closed to new replies.