Title: Related posts without plugin;What I&#8217;m doing wrong ?
Last modified: August 19, 2016

---

# Related posts without plugin;What I’m doing wrong ?

 *  [dunkkan](https://wordpress.org/support/users/dunkkan/)
 * (@dunkkan)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/related-posts-without-pluginwhat-im-doing-wrong/)
 * I’m trying to retrieve the tags from the main loop, and, instead of print them,
   get the titles of all other posts matching those tags.
 * My code:
 *     ```
       <?php
       $posttags = get_the_tags();
       ?>
   
       <?php
        $posts = get_posts('tag=$posttags');
        foreach($posts as $post):
           setup_postdata($post);
       ?>
       <a href="<?php the_permalink(); ?>"><h4><?php the_title(); ?></h4></a>
       <?php endforeach; ?>
       ```
   
 * Thanks for any tip..

The topic ‘Related posts without plugin;What I’m doing wrong ?’ is closed to new
replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [dunkkan](https://wordpress.org/support/users/dunkkan/)
 * Last activity: [17 years, 9 months ago](https://wordpress.org/support/topic/related-posts-without-pluginwhat-im-doing-wrong/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
