I need to change the output of my custom fields based on whether or not there is a specific word in the text field.

For example, I need to show the French flag if a text field contains the word "France." Is that a possibility, and how would I go about it?



What you can do is:

$string = get_field( 'your_field_name' );
if (strpos($string , 'France') !== false) {
   // do your thing

You can use the stripos for case-insensitive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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