Adjusting the display of WooCommerce Related Products on your product pages can enhance your store’s layout and style. By implementing these changes, you create a better shopping experience for your customers. Additionally, this can lead to increased sales.
To customize the WooCommerce Related Products display, you can use the following code snippet:
remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
add_action('woocommerce_after_single_product_summary', 'codebykp_custom_related_products', 20);
function codebykp_custom_related_products() {
echo '<h2>' . __('You may also like', 'woocommerce') . '</h2>';
woocommerce_related_products(array(
'posts_per_page' => 4, // Display 4 related products
'columns' => 2,
));
}