vendredi 4 septembre 2020

IF statement php displaying content if another is empty

I have some fields (Wordpress) and sometimes one of them is empty. I want to display the content of 'the_excerpt' when the 'short_description' is not filled in.

here is what I came with:

    if (empty(the_field('short_description'))) {
      the_excerpt();
    } else {
      the_field('short_description'); 
    }

Unfortunately it displays both short_description and the except after that. What is wrong here? Do I miss something? For me the code looks good.

Aucun commentaire:

Enregistrer un commentaire