Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Most viewed posts


Subscribe to RSS feed


ACF Link Picker shortcode

Stanislav KhromovStanislav Khromov

A shortcode for displaying Link Picker fields in Advanced Custom Fields!

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 4
  • CG
    Posted on

    CG CG

    Reply Author

    Hi there.
    Tried to add the code to functions.php , testes the shortcode and didn’t work…
    Any ideas?


    • Stanislav Khromov
      Posted on

      Stanislav Khromov Stanislav Khromov

      Reply Author

      Hard to say. Are you sure that the `field` attribute matches the name of your ACF Field? You can try using `var_dump(get_field(‘field_name’));` in a template to see if you can get the `field_name` field to show up. If it does, it should work like this as well: `[acf_link_picker field=”field_name”]`


      • CG
        Posted on

        CG CG

        Reply Author

        Hello again.
        Yes, the name is correct, i’ve tested it.
        The field name is “product” and I changed on your code “‘field’ => ‘mylink'” to “‘field’ => ‘product'”.
        Am I wrong?

        It only displays on the text field with the shortcode, the shortcode itself.


        • Stanislav Khromov
          Posted on

          Stanislav Khromov Stanislav Khromov

          Reply Author

          It sounds like the shortcode didn’t get loaded properly. Add the code in your themes functions.php file or in a plugin.