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


Subscribe to RSS feed


ACF Link Picker shortcode

Stanislav KhromovStanislav Khromov

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

Full-stack impostor syndrome sufferer & Software Engineer at Schibsted Media Group

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.