2

I have a very simple question (I hope). I am trying to edit the number of products displayed on my Shop page in my WooCommerce WordPress site, and all attempts thus far have been unsuccessful. I have come across some documentation stating that you can put dd_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 ); in the functions.php file but I am unable to find the PHP file.

I have searched all through the root WP folder, /wp-content/plugins/woocommerce folder, /wp-content/plugins/woocommerce/includes folder and /wp-content/plugins/woocommerce/templates/ folder through an FTP client and haven't found anything.

Where is it?

  • 1
    It is found at /wp-content/themes/YOUR_THEME/functions.php – czerspalace Nov 20 '15 at 1:08
1

Woocommerce is a plugin. The functions.php file is a Theme component, which is auto-loaded by WordPress Core when the theme boots.

While Woocommerce, or any other plugin, may have a file named functions.php but such is not required and it is not the functions.php typically referenced here and elsewhere when people suggest adding code that file, and a file of that name used by a plugin won't be auto-loaded by Core but would have to be loaded by plugin code.

There are Woocommerce themes, which probably have a functions.php, though functions.php is not a required theme file.

0

I would suggest you to create a functions file for Woocommerce. A file like functions4woo.php in your theme folder, because you probably will need to add more functions to WC and will be easier to work things if they're in diferent files. So you would have the Wordpress functions.php and functions4woo.php that would serve Woocommerce.

Doing this you need to add the following to functions.php

// WOOCOMMERCE FUNCTIONS
function functions4woo()
{
   // Here we load from our includes directory
   // This considers parent and child themes as well    
 locate_template( array( 'functions4woo.php' ), true, true );
}
add_action( 'after_setup_theme', 'functions4woo' );
// END WOOCOMMERCE FUNCTIONS

I prefer this way so I get things organized.

Good luck to your project.

H.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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