WordPress.org

Support

Support » How-To and Troubleshooting » Show a custom field value(s) for a specific key, echo it and link it

Show a custom field value(s) for a specific key, echo it and link it

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    @otto42

    WordPress.org Tech Dude

    While it’s poorly documented at the moment, post_custom will do this somewhat simpler, if you’re in The Loop.

    $value = post_custom('key');
    That gets all the custom values you have for that key on the current post. If there’s only one of them, then it will be a string you can simply echo. If there’s more than one, then it will be an array of strings that you can loop through with a foreach or similar.

    Thanks Otto, I will bear this in mind…I am just a total rookie with php so I truly appreciate a pro sparing a thought..actually if you don’t mind I would appreciate a better explanation of what you wrote…maybe with a simple example..thanks!

    I did something similar to display a list of links through custom fields. http://www.bloggingtips.com/2008/08/02/wordpress-custom-field-array/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show a custom field value(s) for a specific key, echo it and link it’ is closed to new replies.