• Resolved ghp123

    (@ghp123)


    I want to make some text show up if a custom field has a curtain value.

    I am looking around and i find how to get it to work if the custom field has any value but if would like to only show it if the value is “123” and not when it is “567”

    How can i make this work?

    I am not smart with php at all so i normally try a bunch of code if find to make things work but this time i get stuck.

    is there an easy way to do this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • ghp123,

    You would just need to add a conditional like:

    <?php $your_custom_field = get_post_meta($post->ID, 'your_custom_meta', true);
    if ( $your_custom_field == 'textstring' ) {
    echo $your_custom_field;
    } ?>
    Thread Starter ghp123

    (@ghp123)

    Thanks so much Rachel,

    That does the trick ??

    just one more question.

    Can i use else if in this to and if so how

    Or would it be better to make the same if for another value?

    Thread Starter ghp123

    (@ghp123)

    I got it all figured out ??

    Thanks Rachel for the help

    Can you please share?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to do something if custom field has value x’ is closed to new replies.