-1

I want to move the related products in this position:

woocommerce_after_single_product_summary

Currently is in:

woocommerce_after_single_product

You can check the positions here.

This is what I tried so far, I added this code in the single-product.php file:

<?php
 do_action( 'woocommerce_after_single_product_summary' );
 woocommerce_output_related_products();
?>

The problem with this is that duplicates the related products section.

Thanks!

closed as off-topic by Michael, Nathan Johnson, Mark Kaplun, Jacob Peattie, Jack Johansson Mar 27 '18 at 15:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1

Related Product Section is already in the woocommerce_after_single_product_summary hook. Now You need to change the priority. Related Products Priority is given: 20 If You want to show it before product tab section, then you have to make the priority less than 10. such as 9

    /**
     * Hook: woocommerce_after_single_product_summary.
     *
     * @hooked woocommerce_output_product_data_tabs - 10
     * @hooked woocommerce_upsell_display - 15
     * @hooked woocommerce_output_related_products - 20
     */
    do_action( 'woocommerce_after_single_product_summary' );

Let's see how to change the priority. First of all, I have removed the default priority of related_products.

remove_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);

Finally, I have reset the pririty as 9.

add_action('woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 9);
  • Thank you for answering but the remove_action is not working in my functions.php, any idea why isn't working? – LIB Mar 27 '18 at 7:08
  • I think it works. Whether it works to test it, you can use only remove_action() first. Then, it will remove the related product section. ( share me the link ) – Mohammad Tajul Islam Mar 28 '18 at 0:26

Not the answer you're looking for? Browse other questions tagged or ask your own question.