Can't display thumbnail photo for next and previous posts
-
I am working on a portfolio website. Whenever a portfolio piece is clicked, the user is taken to a page that shows details about that piece (i.e. more photos and information). There will also be previous and next navigation links to get to additional pieces. However, I want the previous and next navigation links to be a thumbnail photo of the next piece (custom field for that is thumbnail_photo). This is what I have so far:
<?php $previous_post = get_previous_post(); $next_post = get_next_post(); $prev_value = get_post_meta( $previous_post->ID, 'materials', $single = true); $next_value = get_post_meta( $next_post->ID, 'thumbnail_photo', $single = true); ?> <p><?php echo $prev_value; ?></p> <p><?php echo $next_value; ?></p>
I used ‘materials’ in the call for $prev_value since ‘materials’ is another custom field. I just wanted to see if it was actually working. It outputs the materials just fine, but it only outputs the ID number of the thumbnail_photo. I can’t get it to reference the file name so that I can output the actual image.
I am using the Advanced Custom Fields plugin, so each image is stored as an image object. So this is how I would typically output a thumbnail image:
<?php $image = get_field('thumbnail_photo); echo $image[sizes]["thumbnail"]; // thumbnail is a reference to wordpress' thumbnail media size ?>
- The topic ‘Can't display thumbnail photo for next and previous posts’ is closed to new replies.