samedi 27 juin 2015

php with not empty, if, else outputs both

I am running into a confusing problem with my php code edits within Wordpress. I am using a module which allows the the use of custom fields, called by the_field(custom_field).

My code is as follows:

<?php
$relatedlink = the_field('related_link');
if (!empty($lexilelink)) {
?>
    Related Link: <a href="<?php the_field('related_link'); ?>" target="_blank"><?php the_field('related_link_name'); ?></a> 
<?php
} else { echo "No related links";}  ?>

The field "related link" is populated. What ends up happening is it outputs both the if and the else. (I've tried using isset instead of !empty).

Aucun commentaire:

Enregistrer un commentaire