• Resolved harslannet

    (@imhakanarslan)


    Hi,

    WooCommerce related products show the first (oldest) products added in the category.

    I thought this would improve with this code, but again it brings out the old products, just sorting them in itself;

      add_filter( 'woocommerce_output_related_products_args', 'change_related_products', 20, 1 ); 
    function change_related_products( $args ) {    
    	 $args = wp_parse_args( array( 
    	'posts_per_page' => 12,
    	'columns' => 12,  
            'orderby' => 'date',  
    	'order' => 'desc'
    	 ), $args ); 
     	return $args;
    }
    • This topic was modified 5 years, 4 months ago by harslannet.
    • This topic was modified 5 years, 4 months ago by harslannet.
Viewing 1 replies (of 1 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    I would first test if there is anything interfering by playing around with your $args. For example: 'order' => 'desc' >> 'order' => 'asc' – if your edits get overwritten, you know you have a race condition and can try to increase the priority on your hook or find the other method that is interfering and see if you manipulate the loading order there.

    Kind regards,

Viewing 1 replies (of 1 total)
  • The topic ‘Why do WooCommerce related products show the oldest products?’ is closed to new replies.