Quick Question for someone who knows their wordpress.
I’m using the following code to show the WC product gallery on the product page (in the right order).
Someone can quickly point me in the direction of including the image caption between the <p>
‘s?
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
echo '<div class="flexslider"><ul class="slides">';
foreach( $attachment_ids as $attachment_id )
{
echo '<li>';
echo "<img src=".$image_link = wp_get_attachment_url( $attachment_id, 'large').">";
echo '<p>';
echo '</p>';
echo '</li>';
}
echo '</ul></div>';
Here is the way to achieve it:
First of all add below code to your theme’s
functions.php
:After that you can use it like :
So your final code would be :
Source: wordpress topic forum
You can use
wp_get_attachment_metadata
. Something like: