Home › Forums › Pro Support › Output Custom Field in Div Class › Reply To: Output Custom Field in Div Class
July 27, 2018 at 5:59 pm
#5437
Keymaster
It would be something like this:
add_action( 'wpsp_after_content', 'tu_add_custom_meta' );
function tu_add_custom_meta() {
$meta = get_post_meta( get_the_ID(), '_custom_meta_key_name_here', true );
$another_meta = get_post_meta( get_the_ID(), '_another_custom_meta_key_name_here', true );
$one_more = get_post_meta( get_the_ID(), '_one_more_custom_meta_key_name_here', true );
if ( isset( $meta ) && '' !== $meta ) {
echo '<div class="my-class-here">' . $meta . '</div>';
}
if ( isset( $another_meta ) && '' !== $another_meta ) {
echo '<div class="another-class-here">' . $another_meta . '</div>';
}
if ( isset( $one_more ) && '' !== $one_more ) {
echo '<div class="one-more-class-here">' . $one_more . '</div>';
}
if ( function_exists( 'get_field' ) ) {
$image = get_field('image');
if ( ! empty( $image ) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<?php endif;
}
}