Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WooCommerce Featured Image Loop
<?php //<~ don't add me in
add_shortcode ('woo_featured_image', 'woo_featured_image_loop' );
/**
* Create WooCommerce Featured Image Loop Slider
*/
function woo_featured_image_loop() {
ob_start();
// Setup your custom query
$args = array( 'post_type' => 'product'); // Swap to Product
$loop = new WP_Query( $args );
echo '<div class="featured-product-slider">'; // Give you slider container a CSS class
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div> <a href="<?php echo get_permalink( $loop->post->ID ) ?>">
<?php the_post_thumbnail('large'); ?></a>
</a></div>
<?php
endwhile;
echo '</div>';
wp_reset_query();
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.