In this article we’re going to take a look at how to change the related products position within the individual WooCommerce product pages.
The Related Products Hook:
The related products are shown within the woo_commerce_after_single_product_summary hook.
The other items shown within this hook are:
Woocommerce_output_product_data_tabs – 10
Woocommerce_upsell_display – 15
Note: Some themes will already have a different structure based on pre-selected page templates, custom WooCommerce templates and the different product page structures that are available. So the hook positioning may have changed from the default, in this case you will need to apply any of these tweaks to your updated theme structure.
Product Hook Details:
As shown by the above, the upsell items and the product data tabs have respective priorities of 15 and 10. The specific hook for the related products is:
Woocommerce_output_related_products – 20
As shown the priority for the related products is 20. So in order to change the position of the related products we need to change the priority of the related products to be below either of the other two items.
The first step to adjusting the position is to unhook the current item; this can be done by removing the action.
The Code:
By adding the code below to your functions.php the action for the related products section is removed.
remove_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 20);
So in basic terms the above code snippet unhooks the woocommerce_output_related_products section allowing us to assign a new priority.
Next we want to assign a new priority to the action as such:
add_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 12);
The above example sets the priority of the action to 12 so it should appear between the data tabs and the upsell items.
To set the related products above the product data tabs you would add the code:
add_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 8);
So overall this would look something like this:
Placed between the product tabs and upsell items:
//Move the WooCommerce Related Products up Within the After Product Summary Section
remove_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 20);
add_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 12);
Or:
Placed at the top of the after product summary:
//Move the WooCommerce Related Products up Within the After Product Summary Section
remove_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 20);
add_action('woocommerce_after_single_product_summary','woocommerce_output_related_products', 8);
Summary:
This is a fairly easy way to adjust the positioning of your related products, be sure to follow the standard safe steps for adding a code snippet to your functions.php file or take a look at our article on adding functions to WordPress here:
Adding Functions to WordPress
If you found this article useful we would really appreciate a like and a share thanks!








