Show post with same tags which is not only the first tag (2 posts)

  1. jumust
    Posted 3 years ago #

    I have this template http://pastebin.com/n21V6zKF, as you can see in the highlighted parts the code will get only posts based on the first tag.

    I want to get posts from every tag.

    I tried some code that I found in this thread http://wordpress.org/support/topic/show-posts-with-same-tags-as-current-single-post but couldn't get it work.

    I also moved the <?php endwhile; endif; ?> above the "Related Posts" code so that it's not in the loop but I'm not sure why it's not working. Any ideas?

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #


    $tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
          if ($tags) {
             'tag__in' => $tags,
             'post__not_in' => array($post->ID),


Topic Closed

This topic has been closed to new replies.

About this Topic