WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would I call out additional posts that have a tag by that matches the current post's title? For example if the current posts is titled "opossum" I would like teasers from all posts tagged with "opossum" to show at the bottom of the page.

share|improve this question

migrated from stackoverflow.com Jun 22 '12 at 22:53

This question came from our site for professional and enthusiast programmers.

First you need to fetch the current category, then grab posts. So, try

global $post;
$category = get_the_category($post->ID);

$args = array( 'numberposts' => -1, 'offset'=> 1, 'category' => $category );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
share|improve this answer
I added that to my template now I'm getting 'Catchable fatal error: Object of class stdClass could not be converted to string in /mnt/www/wordpress/wp-includes/query.php on line 1450' – Sam Jun 22 '12 at 21:37
I have flagged this to be moved this to the StackOverflow for wordpress – Ryan B Jun 22 '12 at 21:41
$title_tagged_posts_query = new WP_Query( array(
    'tag' => strtolower( get_the_title() )
) );

while ( $title_tagged_posts_query->have_posts() ) : $title_tagged_posts_query->the_post();
    //Output whatever you want here.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.