SOLVED IN 1.4: Shortcode in the Loop Query

Hi,

I have a query loop and I am trying to count the number of posts each term has. I created a shortcode that takes the term_id as an argument, as I thought I could pass the value by using a merge field in the shortcode field which I had added to the query loop. The issue is that the merge tag value doesn’t get passed to the shortcode function, instead it’s just the merge tag text itself that gets passed.

Is there a way to to do this? or is there another way to do this?

Thanks,
Ger

1 Like

Hello @gerhalligan

Welcome to the Bricks forum.

Unfortunately, the dynamic data tags are replaced after the shortcode render, so it won’t work as you expect.

If it is a terms loop, in the shortcode callback you could get the term_id by using the following helper function:

$term_id = \Bricks\Query::get_loop_object_id();

I hope this helps.

Hi Luis,

That did the trick :slight_smile: Thank you very much for your help :+1:

Thanks,
Ger