Site logo

Archived topic

do_shortcode -> image gallery -> attachment page

3 replies · Started by Ernst Wilhelm on December 4, 2022

Viewing posts 1–4 of 4

Hi.

Building an attachment page I am struggeling with the image itself when I try to use a lightbox for it.

`$shortcode = "[justified-image-grid ids=" . $post_id . "]";
echo do_shortcode( $shortcode );`

Adding a dynamic shortcode I can't make it work.

Can you give it a thought?

Hi there,

Not sure if I fully understand. This doesn't sound like a theme related issue though.

Am I missing something here?

If it's more a general WordPress coding question then I'd recommend a forum like this one:
https://wordpress.stackexchange.com/

I wanted to execute a shortcode via echo do_shortcode('[justified-image-grid ids="nnnn"]') , combined with a $variable for the 'nnnn' part. This didn't work. A static shortcode like echo do_shortcode('[justified-image-grid ids=featured]') worked for me, but setting the featured image manually. That (version a worked fine, version b didn't work) was the reason to ask you and not any community like stackexchange.

Now I found a solution. I could make the image in the attachment page to the featured image of that page (with set_post_thumbnail()). After that I could use a static shortcode [justified-image-grid ids=featured] as mentioned before.

Thanks for your help

Glad to hear :)

This archived topic is closed to new replies.