Return Custom Post Type from a Custom Post using a Custom Taxonomy (2 posts)

  1. cumquat
    Posted 2 years ago #

    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;
    			'category__in' => $category_ids,
    			'post__not_in' => array($post->ID),
    			'showposts'=>5, // Number of related posts that will be shown.
    			'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()) {
    			<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    			echo '</ul>';



  2. cumquat
    Posted 2 years ago #



Topic Closed

This topic has been closed to new replies.

About this Topic