Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How would I show posts that have a tag who's name matches the title of the current post? For example if you are on a post called "Hippo" at the bottom of the page I would like posts with the tag "Hippo" to be displayed.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The query would look something like this:

$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.
endwhile;

This assumes that the tag slug for "Hippo" is "hippo", which should normally be the case.

share|improve this answer
    
Thanks but I'm having a heard time getting it to output content. Does it work similar to a querypost? for example where you have the comment I put echo get_post_meta($post->ID,'videoembed',true) ; and I get nothing output. –  Sam Jun 22 '12 at 23:01
    
It should work similarly - have you make sure to declare $post as a global? (global $post). As an alternative, you could use the get_the_ID() function: get_post_meta( get_the_ID(), 'videoembed', true ); –  Andy Adams Jun 22 '12 at 23:06

Your Answer

 
discard

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.