woocommerce offtopic - How can I custom order the product display?

I want to put this:[products ids="17,32,12,1,57"]And I want them to display in EXACTLY this order. Is this pos

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?

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?

Share Improve this question asked Dec 3, 2019 at 22:34 user847288user847288 211 gold badge1 silver badge4 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 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;
}

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744942067a4602386.html

相关推荐

  • woocommerce offtopic - How can I custom order the product display?

    I want to put this:[products ids="17,32,12,1,57"]And I want them to display in EXACTLY this order. Is this pos

    1天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信