Support » How-To and Troubleshooting » [Resolved] Conditional text

[Resolved] Conditional text

  • 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:

  • Blue or black: <?php echo c2c_get_custom(‘blueorblack’); ?>
  • What kind of blue: <?php echo c2c_get_custom(‘whatblue’); ?>
  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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; ?>

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Conditional text’ is closed to new replies.