WordPress.org

Forums

Similar Posts
not showing any posts (3 posts)

  1. deepbevel
    Member
    Posted 4 years ago #

    I've configured the plugin to show posts with the same tag, category and author. but it says "none found" even though all posts in a single category have the same tag, and same author. They are private posts so I set it accordingly. I'm using the widget. Is there something else I have to do? does it not work in an archive? Although it doesn't return any results an post single either.

    http://wordpress.org/extend/plugins/similar-posts/

  2. Gadgetgod
    Member
    Posted 4 years ago #

    Hi Deepbevel, try installing the "Post-Plugin Library" plugin aswell and let me know if it works :)

    Thanks,
    -GG

  3. deepbevel
    Member
    Posted 4 years ago #

    I did install that first, as instructed. It just wouldn't show any results. However I found code that gives me exactly what I was looking for:

    <?php
    //for use in the loop, list 5 post titles related to first tag on current post
    $tags = wp_get_post_tags($post->ID);
    if ($tags) {
      echo 'Related Posts';
      $first_tag = $tags[0]->term_id;
      $args=array(
        'tag__in' => array($first_tag),
        'post__not_in' => array($post->ID),
        'showposts'=>5,
        'caller_get_posts'=>1
       );
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
          <?php
        endwhile;
      }
    }
    ?>

    It's odd though, I tried about 7 plugins which are supposed to return posts of the current tag, none worked. Why this code can do it I'll probably never know.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Similar Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic