New Landing How can we help? Themeforest Theme Support Dante Change number of Related Products

Viewing 4 posts - 16 through 19 (of 19 total)
  • Posted in: Dante
  • #235093
    Armannas
    Member
    Post count: 17

    Not sure if I should have made my own topic, however I have the very same issue.
    The filter code snippet did not work for me either. What was the solution?

    I am trying to limit the related products to 4 items all in 1 row (instead of the carousel with a lot of related products)
    Preferably, I would like to choose the order in which the 4 related products appear, because cross-sells that I have explicitly chosen have lower priority(more on the right), than random related products chosen by Woocommerce at this moment. Would that be possible?

    Here is an example page

    #235545
    David Martin – Support
    Moderator
    Post count: 20834

    Hi,

    I have this working, please add it to your child theme functions.php file.

    /**
     * WooCommerce - Change Related Product Count
     * --------------------------
     *
     * Change number of related products on product page
     * Set your own value for 'posts_per_page'
     *
     */ 
    
    add_filter( 'woocommerce_related_products_args', 'sf_custom_related_products_args' );
    function sf_custom_related_products_args( $args ) {
    	$args['posts_per_page'] = 2; // 4 related products
    	return $args;
    }

    Thanks.

    #236674
    Armannas
    Member
    Post count: 17

    Worked perfectly, thx!

    #236703
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Great thanks to David.
    Thanks
    Mohammad

Viewing 4 posts - 16 through 19 (of 19 total)

You must be logged in to reply to this topic.