Support » Plugin: Code Snippets Extended » Pass parameters into the snippet

  • Resolved elzix

    (@elzix)


    It would be cool if one was able to pass parameters into the shortcode, like:

    [rsnippet id="5" name="book-hotel" hotel="pearlsprings"]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author aftamat4ik

    (@aftamat4ik)

    it’s done for now. jus use $atts[“hotel”] for example

    Cant get this to work. Can u post a more detail solution?

    Post like:
    [rsnippet id="5" name="mysnippet" hotel="pearlsprings"]

    and the snippet goes:

    <?php
    $hotel = $atts[“hotel”];
    echo $hotel;
     ?>

    This does not work.

    Anyway. I need to pass this argument: [wpmem_field hotel_name]
    Testing this on the snippet “Test args” seems to work.
    But when i call the snippet from a post, it does not work:

    [rsnippet id="5" name="mysnippet" hotel="[wpmem_field hotel_name]"]

    The problem is parsing the [ ] as an argument.
    Any suggestions to parse this kind of args?

    • This reply was modified 2 years, 9 months ago by andreasrenn.
    • This reply was modified 2 years, 9 months ago by andreasrenn.
    • This reply was modified 2 years, 9 months ago by andreasrenn.
    • This reply was modified 2 years, 9 months ago by andreasrenn.
    • This reply was modified 2 years, 9 months ago by andreasrenn.
    Plugin Author aftamat4ik

    (@aftamat4ik)

    hm, you pass shortcode as argument?
    Ok i try to fix this.

    Plugin Author aftamat4ik

    (@aftamat4ik)

    So i have ansver for you.
    You cannot do like this:
    hotel="[wpmem_field hotel_name]"
    But!
    You can do like that:
    [rsnippet id="5" name="mysnippet"][wpmem_field hotel_name][/rsnippet]

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Pass parameters into the snippet’ is closed to new replies.