• hi

    i want show related post by tag from sprcific category
    im using this code..

    <?php
    //for use in the loop, list 5 post titles related to first tag on current post
    										$backup = $post; // backup the current object
    										$tags = wp_get_post_tags($post->ID);
    
    										$tagIDs = array();
    										if ($tags)
    										{
    										$tagcount = count($tags);
    										for ($i = 0; $i < $tagcount; $i++) {
    										$tagIDs[$i] = $tags[$i]->term_id;
    										}
    										$args=array(
    										'tag__in' => $tagIDs,
    										'post__not_in' => array($post->ID),
    										'showposts'=>5,
    										'caller_get_posts'=>1
    										'cat'=>15
    										);
    										$my_query = new WP_Query($args);
    										if( $my_query->have_posts() )
    										{
    										while ($my_query->have_posts()) : $my_query->the_post() ; ?>
    										 <h6><?php the_title(); ?></h6>
    										<?php endwhile;
    
    										}
    										} else echo "<p>No related posts were found!</p>";
    										$post = $backup; // copy it back
    										wp_reset_query(); // to use the original query again
    
    										?>

    any help would be great

    thanks

  • The topic ‘show related post by tag from specific category’ is closed to new replies.