Created
October 2, 2020 23:26
-
-
Save neilgee/b9dd5cbc8eb57e2b83712ea2d891303a to your computer and use it in GitHub Desktop.
WooCommerce Featured Image Loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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