My guess is that your problem is that your field type is returning some non-empty value, even if it’s not a URL. For instance, do you have “http://” set as a default value for that field in the admin? If that were the case you could need to use the following as your test:
if( $values || $values !== 'http://' )...
Alternately, your field may be returning an empty array or some other kind of “unechoable” value.
Try putting var_dump( $values )
after you set the $values
variable and see what you’re working with. Then adjust your if()
statement to account for other possible non-empty values you may want to weed out before outputting a link.
Update: Another issue
Also, you shouldn’t use the_field()
in an echo statement since the_field already echos its output. Change this:
echo '<a rel="lightbox" href="'.<?php the_field('cardiac'); ?>.'">Cardiac</a>';
To this:
echo '<a rel="lightbox" href="'. $values .'">Cardiac</a>';