-3

I have trouble with Advanced custom post

I tried to add select box "K dispozicii is "free" and "Obsazeno" is "occupied" and I need to change colors green for free, red for occupied

here is the code

<p><?php the_field("status"); ?> </p>

and the site http://senior-komplex.cz/byty-pro-seniory-melnik-2/

1 Answer 1

1

You will need to store the field value in a variable and use the get_field() instead of the_field() function. From there you can introduce your own custom control structure to set the color you want.

Here is a snippet

     <?php 
   //store the value in a variable first
   $option = get_field("status"); 
    if($option=="K dispozicii"){
     ?> <p style="color:green">$option</p> <?php
        }elseif ($option=="Obsazeno") {
           ?> <p style="color:red">$option</p> <?php 
        }
    ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.