WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. jennsweb
    Member
    Posted 1 year 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?
    Cheers,
    Jenn

  2. jennsweb
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

  4. jennsweb
    Member
    Posted 1 year 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
    Member
    Posted 1 year ago #

    Ah, okay. Glad it's solved.

Topic Closed

This topic has been closed to new replies.

About this Topic