WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Conditional text (3 posts)

  1. tiedemies
    Member
    Posted 4 years ago #

    Hello everyone,

    How can I make just plain text conditional and depending on custom field value?

    Let´s say I have custom field with the name "Do you like blue or black?", possible values being, well "blue" and "black". If the value is blue, there´s another custom field with the name: "What kind of blue" with values like "navy", "deep", etc.

    Now, those fields show on posts like this:

  2. Blue or black: <?php echo c2c_get_custom('blueorblack'); ?>
  3. What kind of blue: <?php echo c2c_get_custom('whatblue'); ?>
  4. How can I make it so that when the value for first question is "black", the "what kind of blue:" text is not shown?

    As you can see I use get custom fields plugin, but it is not necessary if the solution should to be done without it.

    Hopefully I made sense with this, after all I presume this is nothing too complicated, but just can´t get my head around it.

  • nouveller
    Member
    Posted 4 years ago #

    How about:

    Blue or black: <?php echo c2c_get_custom('blueorblack'); ?>
    <?php if(c2c_get_custom('blueorblack') == 'blue') : ?> What kind of blue: <?php echo c2c_get_custom('whatblue'); endif; ?>
  • tiedemies
    Member
    Posted 4 years ago #

    And there it is! Works like a charm. thank you Nouveller, thank you very much.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags