I want to change the number of related products shown on my WooCommerce product page. I found an answer in your response over on the Envato Salient theme page from about a 1 year ago. My question is, how can I do this in my child theme instead of in the parent theme functions.php.? I would like the change to persist through updating but since the function isn't wrapped in if function exists, I can't touch it.
****
"Hi! How can I change amount of related products on a single product page with sidebar? Changes in this sections doesn’t seem to work properly. // display upsells and related products within dedicated div with different column and number of product Thanks!"
ThemeNectar "Hey FRHD! in the functions.php check out these lines: woocommerce_related_products(array('columns' => 4, 'posts_per_page' => 4)); woocommerce_upsell_display(4,4); Also thanks for helping out lfranken Cheers"
For what it\'s worth, I found this filter over in the WooCommerce documentation but it must be referencing something that\'s been changed in the Salient theme:
Couldn\'t nail down how to do it in PHP so I ended up going with this plugin: WooCommerce Product Archive Customiser. For dealing with the same issue, check it out.
Hello,
I want to change the number of related products shown on my WooCommerce product page. I found an answer in your response over on the Envato Salient theme page from about a 1 year ago. My question is, how can I do this in my child theme instead of in the parent theme functions.php.? I would like the change to persist through updating but since the function isn't wrapped in if function exists, I can't touch it.
****
"Hi!How can I change amount of related products on a single product page with sidebar? Changes in this sections doesn’t seem to work properly.
// display upsells and related products within dedicated div with different column and number of product
Thanks!"
ThemeNectar
"Hey FRHD!
in the functions.php check out these lines:
woocommerce_related_products(array('columns' => 4, 'posts_per_page' => 4));
woocommerce_upsell_display(4,4);
Also thanks for helping out lfranken
Cheers"
For what it\'s worth, I found this filter over in the WooCommerce documentation but it must be referencing something that\'s been changed in the Salient theme:
function woo_related_products_limit() {
global $product;
$args[\'posts_per_page\'] = 6;
return $args;
}
add_filter( \'woocommerce_output_related_products_args\', \'jk_related_products_args\' );
function jk_related_products_args( $args ) {
$args[\'posts_per_page\'] = 4; // 4 related products
$args[\'columns\'] = 2; // arranged in 2 columns
return $args;
}
tried to pass the args through a different function to just trim posts but no dice:
add_filter( \'woocommerce_output_related_products_args\', function( $args )
{
$args = wp_parse_args( array( \'posts_per_page\' => 3 ), $args );
return $args;
});
Couldn\'t nail down how to do it in PHP so I ended up going with this plugin: WooCommerce Product Archive Customiser. For dealing with the same issue, check it out.