Quantcast
Channel: User andrewsi - Stack Overflow
Viewing all articles
Browse latest Browse all 51

Answer by andrewsi for PHP If Else shows always ELSE and prints the variable

$
0
0

You're using the wrong function.

the_field will echo out the content of that field, without returning anything. If you want it to return a value, you need to use get_field instead.

Try:

$twit = get_field('twitter'); 

WordPress has a lot of functions that have fairly similar names, and it's worth a little time reading the documentation. As a rule, functions that return a value always start with get_.


Viewing all articles
Browse latest Browse all 51

Trending Articles