WordPress.org

Forums

WooCommerce - excelling eCommerce
Increase number of related products (1 post)

  1. webbrewers
    Member
    Posted 1 year ago #

    Post per page is set at 12, but only 2 related products show. I added the following script to increase that to 4 - which works but it overrides the category/tag filter so products from all cats/tags are included. How can I modify this to show 4 products AND still filter by tag ?

    function woo_related_products_limit() {
    global $product;
    $args = array(
    'post_type' => 'product',
    'no_found_rows' => 1,
    'posts_per_page' => 4,
    'ignore_sticky_posts' => 1,
    'orderby' => $orderby,
    'post__in' => $related,
    'post__not_in' => array($product->id)
    
    );
    return $args;
    }
    
    add_filter( 'woocommerce_related_products_args', 'woo_related_products_limit' );

    https://wordpress.org/plugins/woocommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic