Archived topic
echo custom field not showing in Elements hook
3 replies · Started by Pete on July 30, 2019
Viewing posts 1–4 of 4
I've got the following code to be displayed on 'blog' pages (before content). The featured image and post author display but the custom field doesn't (but the post thumb and taxonomy do). If I place this code in content.php then it does display
<?php if ( the_post_thumbnail('thumbnail', array('class' => 'alignleft')) ) { the_post_thumbnail(); } ?>
<?php the_author(); ?> from
<?php if( get_post_meta($post->ID, "state", true) ): ?>
<?php echo get_post_meta($post->ID, "state", true); ?>
<?php else: ?>nothing<?php endif; ?>
Hi there,
Try this instead:
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) );
} ?>
<?php the_author(); ?> from
<?php if ( get_post_meta( get_the_ID(), "state", true ) ): ?>
<?php echo get_post_meta( get_the_ID(), "state", true ); ?>
<?php else: ?>nothing<?php endif; ?>
Let me know :)
Yup works well Tom. Thanks.
You're welcome :)
This archived topic is closed to new replies.