I built a website with Wordpress ... this is the link
I have this code
<p class="test">
<?php $button_value = get_field('button_name');
if($button_value==0)
{
echo '<a href="?page_id=26" class="get_quote">get quote</a> ';
}else if($button_value==1)
{
echo 'message ';
}
?>
</p>
IF ($button_value==0)
button displays...IF button ($button_value==1)
not displayed message.I do not understand why.
I use Custom Fields plugin.
Can you tell me please how to solve this problem?
If you are using Advanced custom fields, then try to use the number field instead of the text field. Or a better way would be to use a boolean value (like a check box). So when its pressed it will have a value Else it will be empty.
http://www.advancedcustomfields.com/resources/true-false/
<?php $button_value = get_field('button_name');
if( get_field('button_name') ) {
// Value is True
}else{
// Value is false
}
If you are using a text field then anything inside it will considered as string. Which means you are comparing a string against a number. in this case you will have to convert the type of variable into integer. Something like this
$button_value = (int)get_field('button_name');