$link_value = the_field('external-link'); echo '<a rel="nofollow" href="'.$link_value.'" class="btn-custom">Click me</a>'; 

Why is this not working?

  • The second line of code is working. Look for the error in the first line. - Pavel Mayorov
  • Open the generated html and see what is wrong. - u_mulder

1 answer 1

Do this: echo "<a href='".$link_address."'>Link</a>"; , either: echo "<a href='$link_address'>Link</a>"; Play around with quotes ...

  • Unfortunately this did not help, the variable is displayed before the link tag, but not in the "href". what else could be wrong? - skit008
  • @ skit008, the_field - displays, displays something .. Therefore, try replacing the_field with get_field, or something similar. Open the console, look at the errors, maybe something will atm - Niklex
  • get_field helped, thanks a lot) - skit008