Wordpress Tricks

Woocommerce get product gallery images url

How to add custom meta title and meta description in Wordpress?

Woocommerce get product gallery images url

Hello, welcome to therichpost.com. In this post, I will tell you How to get Woocommerce product gallery images url? WordPress is the best cms like I always say. In wordpress custom query post, we will get Woocommerce product gallery images url.

<?php

$args = array(
‘post_type’ => ‘product’
);

// Custom query.
$query = new WP_Query( $args );

// Check that we have query results.
if ( $query->have_posts() ) {

// Start looping over the query results.
while ( $query->have_posts() ) {

$query->the_post();

// Contents of the queried post results go here.
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
/*gallery Images code*/
foreach( $attachment_ids as $attachment_id )
{
$image_link = wp_get_attachment_url( $attachment_id );
}
/*gallery Images code*/

}

}

// Restore original post data.
wp_reset_postdata();

?>

There are so many tricky code in wordpress and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, Angular 8, Angular 9, Angular 10 Nodejs, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.