vendredi 13 décembre 2019

If statement to hide a

I'm pulling both the 'book_series' and 'series_link' from custom fields within Wordpress.

The link shows up correctly when a name and URL are included but it shows "Books Series:' on blank pages (that don't include links or series). How can I hide the content when left blank?

Here is what I have so far:

<?php if (('books_series') == true) : ?>
              <div class="series"><b>Book Series: </b><a href="<?php the_field( 'series_link' ); ?>" target="_blank"><?php the_field( 'books_series' ); ?></a></div>
            <?php else: ?>
              <div class="series" hidden></div>
            <?php endif; ?>

Thank you.

Aucun commentaire:

Enregistrer un commentaire