Support

Account

Home Forums General Issues Using ACF field as URL field inside shortcode

Solved

Using ACF field as URL field inside shortcode

  • Hello there !

    I’m struggling with an issue since this morning and i can’t figure it out.
    I’m using a wordpress plugin called Browser Shots which let me display a small screenshot of any external website. I have a custom acf field called site_url that i set on each post (my posts are basicaly reviews of websites).
    I would like to use my acf field ‘site_url’ as the url parameter but i can’t make it work.
    The shortcode i use in my template is like that :

    [browser-shot url=”http://link-to-website.com”]

    So in order to use my custom field as the url parameter i tried these solutions but nothing works 🙁

    [browser-shot url=”[acf field='site_url']“]
    [browser-shot url=[acf field='site_url']]

    If anyone have an idea that could help me that would be awesome.

    Best regards.

  • This is a limitation of shortcodes, they cannot be used as attributes (parameters) of other shortcodes or html elements.

    The only solutions is to build your own custom shortcode that gets the value of the ACF field and then calls the shortcode from the other plugin.

  • Thanks a lot for your answer!

    I recreated the shortcode as you said and used this code inside to define the url parameter :
    $url = get_field(‘site_url’);

    Works perfectly, thanks again.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.