Categories

Saturday, December 21, 2024
#919814419350 therichposts@gmail.com
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

therichpost
the authortherichpost
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 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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