I’m trying to add a ACF URL Shortcode into an anchor tag to create a button.
So far I’ve tried:
<a class="btn ktblocksvideopop" href="[acf field="youtube_url"]">Watch Video</span></a>
Is this even possible with a shortcode or does it have to be via the default PHP the_field method?.
Any help would be much appreciated.
This is not possible to do with a shortcode because of the way WP processes shortcodes.
To be honest, I’m not sure how to fix it but you could try this (switch to single quotes)
<a class="btn ktblocksvideopop" href="[acf field='youtube_url']">Watch Video</span></a>
Hmmm, unfortunately that didn’t work either. Is there some other way I could create a button using an ACF Shortcocde instead of inserting the field in pre-existing HTML?
According to the documentation it should work https://codex.wordpress.org/Shortcode_API#HTML
The documentation also says something about creating a new shortcode that outputs all of the HTML instead of just the attribute.
Thank you it’s working now, not sure why but I copy/pasted your code first attempt, 2nd attempt manually typed it!.
Is there anyway to make it conditional so it only displays the button if it has a field value?