Home Forums Plugin Support WP User Frontend Pro Showing Custom field label in Post

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  towhid 4 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #40587

    Justin
    Member
    Post count: 1

    Hi there,

    I have managed to add some of my selected custom fields to my single.php post page using the following:

    < ?php echo get_post_meta( $post->ID, ‘contributor_name', true ); ?>

    How can I include the Field label here too, so that it reads (for example): Contributor: Contributor Name

    Many thanks.

    #40629

    towhid
    Participant
    Post count: 4505

    Hello,

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

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

    Thank you ๐Ÿ™‚

    #40811

    Justin
    Member
    Post count: 1

    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?

    #40890

    towhid
    Participant
    Post count: 4505

    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 4 posts - 1 through 4 (of 4 total)

The topic ‘Showing Custom field label in Post’ is closed to new replies.