Okay
  Public Ticket #2704874
shortcode with variable input
Closed

Comments

  • Hans Coomans started the conversation

    Dear, I would like to use the shortcode [ameliabooking employee=1 service=1] with variables: [ameliabooking employee=$variable1 service=$variable2]

    Is this possibe?

    Thanks,

    Hans

  • [deleted] replied

    Hello Hans,

    thank you for purchasing Amelia, and for your kind inquiry!

    You could achieve this with the help of some plugin which has the possibility to use PHP Snippets, and add shortcodes on the page in that way. For example:

    1. There's the page (where you want the booking form to be), and when you're creating links that lead to that page, in URL you need to place the ID for the employee (http://somesite/booking?employee=17)

    2. On that page (where you want the booking form to be), instead of our shortcode, you'd need to add the shortcode of that plugin which uses PHP Snippet which will generate our shortcode (https://wordpress.org/plugins/insert-php-code-snippet/).

    7658442828.png

    3. The snippet would look something like this:

    <?php
    $employee = $_GET['employee'];
    echo do_shortcode( "[ameliabooking employee=$employee]" );
    ?>
    9700784098.png
    3573737381.png

    I hope that helps.