Can't retrieve custom field data with next post link
-
Hello,
I’m trying to use conditional tag with next post link. I want to get data from custom field but its not showing up. the if condition is working but the piece of code im using to get filed data is not working. below is my code
this part isn’t working
<?php echo get_post_meta($nextPost->ID, 'label_value', true); ?>
<?php wp_reset_postdata(); } //end foreach } // end if $nextPost = get_next_post(); if($nextPost) { $args = array( 'posts_per_page' => 1, 'include' => $nextPost->ID ); $nextPost = get_posts($args); foreach ($nextPost as $post) { setup_postdata($post); ?> <a href="<?php the_permalink(); ?>"> <p><?php the_title(); ?> ?</p> <?php // Must be inside a loop. if ( has_post_thumbnail() ) { the_post_thumbnail('thumbnail'); } else { echo '<img width="200" src="<?php echo get_post_meta($nextPost->ID, 'label_value', true); ?>"/>'; } ?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Can't retrieve custom field data with next post link’ is closed to new replies.