Display Values of Custom Fields in Post? (5 posts)

  1. jennsweb
    Posted 3 years ago #

    Hi Folks,
    almost there...I added a function to my functions.php file like so:

    function get_custom_field($key, $echo = FALSE) {
    	global $post;
    	$custom_field = get_post_meta($post->ID, $key, true);
    	if ($echo == FALSE) return $custom_field;
    	echo $custom_field;

    I then experimented with adding <?php the_meta(); ?> to the single.php file.
    This got my custom field keys and values to display in the body of a post. HOWEVER, I only want the values of the keys to display. For example, I have a custom field key called Phone Number. I only want to show the value, i.e. 555-555-1234
    Is there a simple php method that can do that?
    Also, is there a way to make a url that is a custom field value an actual link?

  2. jennsweb
    Posted 3 years ago #

    Just to specify, I can't use the <?php the_meta(); ?> tag alone because it will cause other posts on the site to display too much information. So I guess I am looking for a simple way to only list the values of specific custom fields.

  3. David Choi
    Posted 3 years ago #

  4. jennsweb
    Posted 3 years ago #

    I am already using Gravity Forms Custom Post Types and I've gotten some help from them already. I may try that plugin as well. Thanks!

  5. David Choi
    Posted 3 years ago #

    Ah, okay. Glad it's solved.

Topic Closed

This topic has been closed to new replies.

About this Topic