I'm trying to make a simple widget that displays a list of posts, and is followed by some metadata from each post.
Here is my code:
$eventdate contains the metadata i need to retrieve.
query_posts('');
if (have_posts()) :
echo "<ul>";
while (have_posts()) : the_post();
$eventdate = get_post_meta($post->ID, 'event-date', true);
echo "<li>".get_the_title()." - ".$eventdate."</li>";
endwhile;
echo "</ul>";
endif;
wp_reset_query();
I read an old post on the wordpress support forums about custom loops like this, and I'm fairly certain that I'm not calling the $post_id properly, because if I manually insert a post_id it calls the correct data.. but either way I'm unsure where to go from here. Any help would be appreciated.
get_the_ID()rather than declare global and use$post->ID– Tom Mar 5 '12 at 15:33