Pull custom field values into featured post list
-
I can’t figure this one out so hoping someone can give me a little help!
I have set up some custom fields on a post page (eg – Client = BBC) and they render out fine in the post page (single.php) but I also want that field to render out within a “featured posts” slider on a homepage template that I’m using.
It’s just not showing anything when I use the query I have set up on single.php which is
<ul class="related-information"> <?php global $wp_query; $postid = $wp_query->post->ID; wp_reset_query(); ?> <li><span>Client</span> <?php echo get_post_meta($postid, 'Client', true); ?></li> <li><span>Director</span> <?php echo get_post_meta($postid, 'Director', true); ?></li> <li><span>Format</span> <?php echo get_post_meta($postid, 'Format', true); ?></li> <li><span>Narrator</span> <?php echo get_post_meta($postid, 'Narrator', true); ?></li> <li><span>Producer</span> <?php echo get_post_meta($postid, 'Producer', true); ?></li> </ul>That displays my fields fine on single.php but on home.php (my custom template for the homepage) it shows nothing. I assume I’ve got the query wrong for the homepage but I don’t know how to fix.
Any pointers welcomed 🙂
(I’m not using meta for the fields because that renders out lots of other stuff plugins insert into custom fields)
The topic ‘Pull custom field values into featured post list’ is closed to new replies.