Home Forums Front-end Issues Shortcode in Url ?


Shortcode in Url ?

  • Hello,

    i like to display my custom field like…

    [add_to_cart_url id=”[acf field="mynumber"]“]

    this should display a link like this …

    … /?add-to-cart=123

    But it does not. is there a way to lets display a link with a shortcode in it ?


  • Hi @aleccs

    I’m afraid you can’t do it from the backend editor page. To do that, you need to modify your template by using the do_shortcode() and the get_field() functions.

    I hope this helps 🙂

  • Hi James,

    thank you for the fast response. can you please give me the whole code.
    Iam pretty new and noob about this. with the example its possible to
    better learning the syntax for me.


  • Hi @aleccs

    Here’s an example how to do it:

    $my_number = get_field('mynumber');
    echo do_shortcode('[add_to_cart_url id=' . $my_number . ']');

    Please keep in mind that you need to put it inside The Loop.

    If you have time, please learn more how the template works here:

    If you don’t have time to learn it, I suggest you hire a developer to help you out with it, and I’d recommend looking for one on or

    I hope this helps 🙂

  • Thank you for the quick reply. Can you give me the full idea?
    I’m very new and important about this. With examples it is possible
    Learning syntax better for me. You create the form that you have to decide how you want the results to display.

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

The topic ‘Shortcode in Url ?’ is closed to new replies.