1

I want to put this:

[products ids="17,32,12,1,57"]

And I want them to display in EXACTLY this order.

Is this possible?

0

2 Answers 2

1

You can use woocommerce_shortcode_products_query filter to change orderby argument. it will set orderby as post__in in [products] shortcode query. I have tested and it is working fine for me. you can take reference from below code and adjust code as per your need. Let me know if this works for you!

add_filter( 'woocommerce_shortcode_products_query', 'woocommerce_shortcode_products_orderby_post_in' );
function woocommerce_shortcode_products_orderby_post_in( $args ) {
    if( isset( $args['orderby'] ) ) {
        $args['orderby']  = 'post__in'; 
    }
    return $args;
}
1
  • Looks like that worked! thanks very much!
    – user847288
    Commented Dec 9, 2019 at 3:04
-1

Have you tried to use the orderby="menu_order" parameter in the shortcode? You can set the menu order inside each pruduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.