Showing Custom field label in Post

This topic contains 3 reply and 2 voices, and was last updated by towhid 10 years, 3 months ago
Viewing 3 Posts - 1 through 3 (of 3 total)
Author Posts
April 3, 2015 at 5:39 pm 40587
towhid Hi there, I have managed to add some of my selected custom fields to my single.php post page using the following: ID, 'contributor_name', true ); ?> How can I include the Field label here too, so that it reads (for example): Contributor: Contributor Name Many thanks.
April 4, 2015 at 12:41 pm 40629
towhid towhid

Hello,

Please try the following code and let me know the result.

echo "Contributor:" . get_post_meta( $post->ID, 'contributor_name', true );

Thank you 🙂

April 7, 2015 at 4:23 pm 40811
Justin Justin

Hi thanks for this – this seems to work well BUT when the title “Contributor” still shows even when nothing is added to the field. Essentially, I only want the field title to be visible when the field has been completed.

Any ideas as to how I can do this?

April 8, 2015 at 12:10 pm 40890
towhid towhid

Hello Justin,

Can you try with the following code and let me know the result.

$meta_values = get_post_meta( $post->ID, 'contributor_name', true );
		if (isset($myvalue)){
			echo "Contributor:" . $meta_values;
		}

Thank you 🙂

Viewing 3 Posts - 1 through 3 (of 3 total)