I have a standard Wordpress loop displaying items:
$loop = new WP_Query( array( 'post_type' => 'images', 'orderby' => 'menu_order', ) ); while ( $loop->have_posts() ) : $loop->the_post(); /* loop code, HTML mostly, a few if statements, nothing special */ endwhile;
Now I want to display CERTAIN data from meta boxes and here comes the trouble.
the_meta() works just fine, but get_post_meta() doesn't work at all.
Why is this happening? Any fixes? I need to do something like get_post_meta($post->ID, 'metabox_field', true).
Alright. More details.
I have a custom post type called "images".
Each image item has it's own metabox with a few fields inside, let's call them image_date, image_author, copyrights.
I want to display image author from field called image_author, so:
<?php $author = get_post_meta($post->ID, 'image_author', true); echo $author; ?>
The problem is it works ONLY when I open SINGLE image (single-image.php), but doesn't in loop (and I want to display this data for each item in loop also).
The_meta() works in both places if it changes something.
My loop looks exactly as above.
I guess that's all :)