1

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.

1

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.

  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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