Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other WordPress – Getting specific custom field value

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34936
    afferennen
    Member

    I am trying to get a custom field value from a custom field and use a conditional statement. This is what I want to try to do:

    Inside a post, if, out of the custom field ‘Amount’, the value is ‘Funded’, then do stuff.

    That’s all I want, and I can’t find a way to query it. Can anyone help? I appreciate it.

    #89773
    TheDoc
    Member

    This might work, though I haven’t tried it:

    
    $amount = get_post_meta($post->ID, 'amount', true);

    if ($amount == 'Funded') {
    // do something
    }
    ?>

    This is just a slightly modified version of one of the snippets available here: https://css-tricks.com/snippets/wordpress/using-custom-fields/

    #89790
    dhechler
    Member

    Yeah, TheDoc is right. That should work just fine. If that doesn’t happen to work, you can use this inside the loop


    $amount = get_post_meta(get_the_id(), 'amount', true);

    if ($amount == 'Funded') {
    // do something
    }
    ?>
    #89796
    afferennen
    Member

    Wow I’m dumb. I thought of the hard stuff first. Thanks guys.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.