I’m trying to add the following rollover image with a link inside of a PHP if statement.
but the hyperlink disappears when it is executed
<?php
if(file-info) {
echo " <a href="<?php the_field('file-info'); ?>">Access Application</a>";
} else {
echo "You are logged in!";
}
?>
and
<?php if(file-info): ?>
<span class="rcg-line"><a href="<?php the_field('file-info'); ?>">
Access Application</a></span>
<?php else: ?>
<?php endif; ?>
I tried using both examples above and it doesn’t seem to work.
update
-
I’m using the advanced custom fields plugin for wordpress.
-
file-info is the varible its looking for in which the user entered and the_field is whats used to call it i guess
So OP is talking about: http://www.advancedcustomfields.com/
Try this…
Looks like
the_field
must callecho
.Seems like there are docs on the vendors page. You need to unserstand distinction of ‘string’ literal and a variable. Also
var_dump
is your friend. Finally, please look at other posts which discuss how to enable PHP error reporting. Will save us all a lot of time.If the
the_field
function returns the desired value as a string, you need to echo it, and don’t forget that HTML will want quotes around the value:In your second example you will also want to put quotes around the value, and if
the_field
doesn’t echo the value to the client, you’ll need to echo it’s return:Edit: If the
the_field
function is properly emitting the value, omit theecho
in each example.