WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. webbrewers
    Member
    Posted 4 months 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/

Reply

You must log in to post.

About this Plugin

About this Topic