WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. jumust
    Member
    Posted 2 years ago #

    Hi,
    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
    The Sweeper & Moderator
    Posted 2 years ago #

    try:

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

    http://codex.wordpress.org/Function_Reference/wp_get_post_tags

Topic Closed

This topic has been closed to new replies.

About this Topic