WordPress.org

Ready to get started?Download WordPress

Forums

Quick Custom Fields Question (6 posts)

  1. sumeetjain
    Member
    Posted 8 years ago #

    I would like to output the value of a custom field in my post. That field is called "vid_a" and its value is "something.swf". I don't want a list or anything... Just a simple raw output of the value.

    I've been trying to do this for WEEKS. I began with the function listed in the Codex: get_post_meta.

    But I must be using it wrong, because it doesn't output anything. Any help would be appreciated. The more specific you can be - actual code would be excellent - the more it will help me. Thanks so much for taking the time.

    Sumeet

  2. amory
    Member
    Posted 8 years ago #

    Try this (examle code within readme file)
    http://www.coffee2code.com/archives/2004/06/30/plugin-get-custom/

  3. sumeetjain
    Member
    Posted 8 years ago #

    I just tried that before posting. It creates a lot of "cannot-modify-header" errors.

    Isn't there a way to do this without a plugin?

  4. ifelse
    Member
    Posted 8 years ago #

    Just use
    <?php echo get_post_meta($post->ID, 'vid_a', true); ?>

    get_post_meta just retrieves the value. To output it, you'll need to echo the value returned.

    BTW, as an aside, "cannot-modify-header" errors are usually due to extraneous whitespace.

  5. sumeetjain
    Member
    Posted 8 years ago #

    You'd better watch out, because if I ever find you I might not be able to control myself from giving you a series of embarrassing but curiously refreshing hugs.

  6. ifelse
    Member
    Posted 8 years ago #

    "You'd better watch out, because if I ever find you I might not be able to control myself from giving you a series of embarrassing but curiously refreshing hugs."
    Erm, thanks?:)

Topic Closed

This topic has been closed to new replies.

About this Topic