• Hello,

    I am trying to add a customization with your plugin. I set default products ordering to most recent via customization settings. I have added the following snippet to effect menu ordering + name for specific categories


    add_action( 'pre_get_posts', 'my_wc_custom_order_for_category' );
    function my_wc_custom_order_for_category( $query ) {

        if ( is_admin() || ! $query->is_main_query() ) {

            return;

        }

        // replace 'my-category-slug' with your category slug (or use an array of slugs)

        if ( is_product_category( array('nees-afikseis', 'new-arrivals') ) ) {

            // if the user explicitly selected a sorting from the dropdown, don't override:

            if ( isset( $_GET['orderby'] ) && ! empty( $_GET['orderby'] ) ) {

                return;

            }

            //use manual ordering (menu_order) — same as "Default sorting (custom ordering + name)"

            $query->set( 'orderby', 'menu_order title' );

            $query->set( 'order', 'ASC' );

        }

    }

    Without your plugin I can see that it is working, but when I activate your plugin I see that the menu order is effecting all the categories. Is there a way to have your plugin active and have the logic I described?

    Thanks!

The topic ‘Rearenge customization’ is closed to new replies.