ColorlibHQ / simple-custom-post-order

Order posts(posts, any custom post types) using a Drag and Drop Sortable JavaScript. Configuration is unnecessary.
http://wordpress.org/plugins/simple-custom-post-order/
GNU General Public License v3.0
31 stars 20 forks source link

Issue with sorting taxonomies #49

Closed mplusb closed 4 years ago

mplusb commented 5 years ago

https://wordpress.org/support/topic/issue-with-sorting-taxonomies/

sermalefico commented 5 years ago

This cause me disapear all taxonomy queries. Roll back to previus version

tpaviper commented 5 years ago

This fix also broke things for us as well. Line 520 -> $taxonomy = $args['taxonomy'][0]; produces an undefined offset Needs more testing before release.

Editing in a possible solution:

changing your function to this could solve the issue:

public function scporder_get_terms_orderby($orderby, $args) {
        if (is_admin())
            return $orderby;

        $tags = $this->get_scporder_options_tags();

        if (!isset($args['taxonomy']))
            return $orderby;

        $taxonomy = $args['taxonomy'];
        if(is_array($taxonomy) && isset( $taxonomy[0] )  ) { // new addition
            $taxonomy = $taxonomy[0];
        }

        if (!in_array($taxonomy, $tags))
            return $orderby;

        $orderby = 't.term_order';
        return $orderby;
    }