1) If this is in a plugin, are you scoping $post to global, as in:
global $post;
This would (naturally) occur before making use of $post in your code.
2) Tags are not considered a built-in WP component which relates to the posts table, so it would be difficult (if not impossible) to make use of query_posts for something like this.
You wouldn’t be able to use query_posts, but you could do something like this to get the IDs of posts with certain tags:
global $tablepost2tag;
$wpdb->get_results( "SELECT post_id FROM $tablepost2tag WHERE tag_id = $tag" );
It’s not much, since I’ve not had to do anything like #2, but it should get you started.
you would think that wouldn’t you? but the following only produces a list of the titles, am I missing something here? Shouldn’t it produce the title and the post’s details?
<?php
if (have_posts()) :
while (have_posts()) : the_post();
the_title();
print_r($post);
endwhile;
endif;
?>
Question is, where do you have this code running? It works (as expected) when I dump it into my theme’s index.php.
its running in TAG.PHP and is called when the tag archive is called for the Ultimate Tag Warrior plugin
got some reason $post wasn’t globally called, just added
global $post;
and it was all good