I found a bug that if you try to render a dynamic tag inside of the shortcode tag, it won’t render (at least inside of a <Loop> which is how I used it).
If you just type in the ID into the field, then it renders. And if you just do the shortcode inside the <Shortcode></Shortcode> tag, it also renders. But if you want to add a dynamic tag (post id in this case) inside of a shortcode, then it won’t render.
@zack I figured I’d add a note to this thread with a key bit of info you sent me about this issue via DM earlier, and that is that when you replace id="{Field id}" with id="12345" (any actual ID of a template post) your shortcode works as expected, so the issue here doesn’t seem to be the shortcode itself at first glance.
One other thing that might be helpful in troubleshooting this: could you confirm that if you just place <Field id /> inside your loop it outputs the expected ID number? I’m assuming it does based on your experience with the language, but for the sake of cutting out everything that isn’t the issue here, I thought it might be good to confirm.
Hi Zack! I think this is specific to this particular shortcode, since I’ve successfully passed dynamic data to plenty of shortcodes, even ones inside loops, and I’ve just tested to make sure that still works in the current plugin version.
I’ve found a workaround though, and here’s the magic snippet:
Normally I would use the <List> tag to create an array of IDs, but the BB shortcode doesn’t like json array formatting (makes sense) so instead I’m appending the ID of each loop iteration to a variable, and then passing the variable to the shortcode (luckily it seems to handle a comma-separated list just fine)
@julia Thanks for testing this out! That works, but not in the way I need it. Unfortunately I don’t understand the method you used, so I’m having a hard time getting it to output what I need.
What I’m ultimately doing is outputting those shortcodes inside of a slider (each shortcode is a slide). I’m using slick slider, so in my case, each shortcode needs to be wrapped in a <div>.
I’ve switched to using a list to save the IDs output by the post loop, and now I’m using a list loop around the shortcode (which is rendering properly in my tests, so the issue is really limited to putting it in post loops)
The div would not have been so important except for the fact that the BB shortcode outputs more than one div (one that holds the style and one that holds the content). So they need to be wrapped in another div so the slider knows that they are one slide and not two.