I want to dislay wordpress gallery in single.php. I put this code into single.php
<?php echo do_shortcode('[gallery columns="4" ids="1,2,3,4,5,6,7,8"]');?>
The problem is that image ids are changing based on post ID.
I wonder what code should I put? I did:
<?php
$id_image = what_code_should_i_put_here;
echo do_shortcode('[gallery columns="4" ids="'.$id_image.'"]');
?>
But I have no idea the code part.
what_code_should_i_put_here
must result '1,2,3,4,5,6,7,8'
Did you check this one: https://wordpress.stackexchange.com/questions/149268/get-all-image-ids-from-the-media-library? After you get IDs array, you would simply need to convert it to delimited string. Let me know if you need help on that.