• Resolved tcflip

    (@tcflip)


    Hello,

    I want to order by date the related products.

    I use thid code, but doesnt work, any thought?

    add_filter( 'woocommerce_output_related_products_args', 'hff_commerce_child_related_products_args', 99, 3 );
      function hff_commerce_child_related_products_args( $args ) {	  
    	//  echo("RELATED :::");
        $args = array( 
            'posts_per_page' => 4,  
            'columns' => 4,  
            'orderby' => 'date', 
    		'order' => 'DESC'
     ); 
     	return $args;
Viewing 3 replies - 1 through 3 (of 3 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @tcflip!

    See if this works:

    add_filter( 'woocommerce_output_related_products_args', 'hff_commerce_child_related_products_args', 99, 3 );
      function hff_commerce_child_related_products_args( $args ) {	  
        $args = array('post_type' => 'product','posts_per_page' => '3', 'columns' => 4,'orderby' => 'date', 'order' => 'DESC', 'post__not_in' => array(get_the_ID()) );
     	return $args;
    }

    Cheers!

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Howdy!

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.

    Cheers!

    Thread Starter tcflip

    (@tcflip)

    Hello @rynald0s ,

    i tried your solution but didnt worked.

    it still returns random products.

    Best regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Related products order by date’ is closed to new replies.