This picks up the three latest featured products and puts them in the featured pages areas of Customizr’s front page. A pre-requisite to it working is that you set each of the the featured pages to something first (otherwise, the code to display the products is bypassed).
// Substitute featured pages with WooCommerce featured products
add_filter('tc_fp_id' , 'my_woocommerce_featured_product_ids', 10 ,2);
function my_woocommerce_featured_product_ids( $page_id , $fp_id ) {
if ( is_plugin_active('woocommerce/woocommerce.php') ) {
$current_featured_products = wc_get_featured_product_ids(); // returns an array of size (number of featured products) + 1
$number_of_featured_products = (count($current_featured_products) - 1);
// Only sets a featured product if you have at least one featured product
if ( ! ( is_int($number_of_featured_products) && $number_of_featured_products > 0 ) )
return $page_id;
switch($fp_id) {
case "one" :
$page_id = ('publish' == get_post_status( $current_featured_products[0] ) ) ? $current_featured_products[0] : $page_id;
break;
case "two" :
if ( $number_of_featured_products > 1 )
$page_id = ('publish' == get_post_status( $current_featured_products[1] ) ) ? $current_featured_products[1] : $page_id;
break;
case "three" :
if ( $number_of_featured_products > 2 )
$page_id = ('publish' == get_post_status( $current_featured_products[2] ) ) ? $current_featured_products[2] : $page_id;
break;
} // End switch
} // End is_plugin_active
return $page_id;
}
It needs to be pasted in your child theme’s functions.php. (Read How to Customize Customizr if you’ve never done this.)
I have tested this on a local install with dummy products. Let me know if it works for you in a more realistic environment.