Post_in shortcode function

I have been using the shortcode in a gravityforms form which is working great

[template id=1 post_in=2] 

I am now wondering two things:

I use live merge tags in gravityforms to pass data from one field to another using the function by gravitywiz (How to Use Merge Tags in Field Labels with Gravity Forms - Gravity Wiz) I am wondering how I can use the merge tag as the field value for post_id in the shortcode?

I tried

[template id=1 post_in={:2}] 

but it didn’t work

The second question is how to use more than one post_in within a shortcode (so being able to pass multiple values)


Hi Chris,
I have a feeling that since the template renders on page load a merge tag passed to it as a variable wouldn’t update live the way you want it to. You’d maybe need to output a complete Loop of all your posts and use some CSS or JS to only display the post with the post ID from the merge tag.

My first attempt would look something like this:

Each post in your loop would need to have a classname containing its ID (you could use class="{Field postclass}" or class="my-custom-class-{Field id}" on your loop item wrapper.

Then, in an HTML field in your form maybe you could do something like:

  .all-post-items-have-this-class {
    display: none;
  .my-custom-class-@{:2} {
    display: block;

I can’t guarantee that this will work as I haven’t tested it and can’t find documentation about using live merge tags or style tags in the HTML field, but I’m excited to find out if you can get it working!

Depending on the number of posts on your site this isn’t a super efficient query, but it might not matter too much in your use-case. Let me know how it goes!