I am using a PHP function with a simple if else statement. If variable = 100 do something, else do something else.
The data is coming from an ACF Range Field. For some reason, the function always returns the else-statement even though the ACF field is = 100. I figured the problem is the if-statement where I've tried to use: =, ==, !==, === or >=. If I change it to single = then it always returns h2 Something but all the rest returns h2 something else no matter what value I put in the ACF Range field.
function hovsa_shortcode() {
$full_tegnet = get_field("tegnede_andele_");
if ( $full_tegnet == '100' ) {
return '<h2>Something</h2>';
} else {
return '<h2>Something else</h2>';
}
}
add_shortcode( 'hovsa', 'hovsa_shortcode' );
var_dump($full_tegnet)? And what doesstrlen($full_tegnet)return?get_field()with the post id and disable any formatting logic:<?php $full_tegnet = get_field('tegnede_andele_', get_the_ID(), false);If still null, then your field is really null!