The Problem

On the single product, this error may appear above the related proucts if you have updated to WooCommerce 2.1 before updating your theme:

woocommerce_related_products was called with an argument that is deprecated since version 2.1! Use $args argument as an array instead.

The Solution

Ensure your theme is up to date and has not been retired.

If your theme is up to date and still supported, please ensure debugging is NOT enabled on your site. If the site is live, this should be turned off in the wp-config.php and all debugging plugins deactivated. If working on a local setup, then know debug errors will be common. WooCommerce includes these messages to alert developers that a function will be changing in a future version. We are probably aware of it, and just haven’t addressed it in an update yet due to lower priority.

To check the function yourself in a Dynapack theme (Dynamo, flatpack, Capital, Department, etc):

This is considered a modification, and is provided as-is. We expect you understand what you are doing if applying coding changes using these or other WordPress tutorials. Make a backup of your existing file so you can replace it if something goes wrong and you need to start over. Modified files WILL probably be replaced by a theme update at some point, so keep note of your changes for future reference or see our guides below. We cannot assist you with modifying your theme or support problems you encounter as a result!

If you are modifying a theme as part of a client project, the following are really important!

How to Modify Your Theme the Right Way
How to Track Update Changes and Maintain Modifications

1. Open the ocmx/theme-setup/woo-commerce.php file. If this file does not exist, open the root functions.php. We recommend using an HTML editor to do this, or you can download and install the Solid Code Theme Editor to access the file from the WordPress Admin

2. Around line 37 you should see the related products function:

// Displays up to 3 related products on product posts (determined by common category/tag)
function woocommerce_output_related_products() {
woocommerce_related_products(3,1); // Display 3 products in rows of 3

3. As the message indicates, change the argument (the part in parenthesis) to an array that sets how many post to show, like so:

// Displays up to 3 related products on product posts (determined by common category/tag)
function woocommerce_output_related_products() {
woocommerce_related_products(array( 'posts_per_page' => 3 ),1); // Display 3 products in one row


Have you seen Elementor?

You can build almost any Obox theme with Elementor!
With a powerful, fast page builder, Elementor is the best way to get your site online with as little effort as possible.