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 Answer
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.– SamCommented Jun 22, 2012 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 theget_the_ID()
function:get_post_meta( get_the_ID(), 'videoembed', true );
Commented Jun 22, 2012 at 23:06