Tagged: columns, enfold, related products, woocommerce
-
AuthorPosts
-
November 10, 2014 at 9:09 am #348677
Hi,
I’m trying to figure out how to set the number of items & columns displayed in the ‘related products’ area but independent of the general enfold added setting found in woocomerce/settings/products/Column and Product Count/
I have tried the woo-commerce suggested method by adding the following function but it does not work as i assume enfold has overwritten this method.
/** * WooCommerce Extra Feature * -------------------------- * * Change number of related products on product page * Set your own value for 'posts_per_page' * */ 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'] = 6; // 6 related products $args['columns'] = 6; // arranged in 6 columns return $args; }
- This topic was modified 10 years, 1 month ago by raineysw.
November 10, 2014 at 10:24 pm #349080Hey raineysw!
Try adding this to the bottom of your /enfold/functions.php file.
add_action( 'init', 'enfold_customization_change_related_products' ); function enfold_customization_change_related_products() { global $avia_config; $avia_config['shop_single_column'] = 2; $avia_config['shop_single_column_items'] = 4; }
Cheers!
ElliottNovember 10, 2014 at 11:21 pm #349088Hi Elliot,
That seems to work and it appears that ‘5’ is the maximum number of columns supported yes?
Sean.
November 11, 2014 at 4:30 pm #349468Hey!
That’s right, let us know if you have any other questions.
Regards,
ElliottMay 29, 2019 at 8:01 pm #1105265This reply has been marked as private.June 3, 2019 at 6:07 am #1106573Hi,
Try to set the “orderby” parameter to “meta_value_num” and the “meta_key” to “_price”. Example:
add_filter('woocommerce_output_related_products_args', 'avf_woocommerce_output_related_products_args_mod', 10, 1); function avf_woocommerce_output_related_products_args_mod($args) { $args['orderby'] = 'meta_value_num'; $args['order'] = 'asc'; $args['meta_key'] = '_price'; return $args; }
Best regards,
IsmaelOctober 10, 2019 at 11:47 pm #1146976Is there any way to get more product columns (for related as well as in the product slider) as 5?
Unfortunality 5 is to less for bigger shops in these days. way to much space wasted with 5 products only.
Thx in advance for fast help :)
October 11, 2019 at 11:39 am #1147087Hi,
@Caiven: Thank you for the inquiry. How did you add the products? Are you using Product Grid element? You can use the following hook to increase the number of items in the related products section.function avia_chance_wc_related_columns(){ global $avia_config; $avia_config['shop_single_column'] = 5; // columns for related products and upsells $avia_config['shop_single_column_items'] = 5; // number of items for related products and upsells } add_action('wp_head', 'avia_chance_wc_related_columns', 6);
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.