Skip to content

Instantly share code, notes, and snippets.

@neilgee
Created October 2, 2020 23:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilgee/b9dd5cbc8eb57e2b83712ea2d891303a to your computer and use it in GitHub Desktop.
Save neilgee/b9dd5cbc8eb57e2b83712ea2d891303a to your computer and use it in GitHub Desktop.
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