Background: WooCommerce provides a shortcode to display recent products any place I want.
<?php echo do_shortcode('[recent_products columns="3"]'); ?>
There is an argument in WP_Query named offset that allows us to pass over desired number posts.
<?php $query = new WP_Query( array( 'offset' => 3 ) ); ?>
So, if I use the above query to loop over posts, the first result I’d get would be the fourth latest post. Right?
Question: I was wondering if it would be possible to extend WC’s Recent Posts shortcode to accept offset argument?
You’ll have to change in
wp-content/plugins/woocommerce/includes/class-wc-shortcodes.php
therecent_products()
method like that:With this an
offset
attribute is added (default 0) that will be used in WP_Query.