• Resolved mathiasdb

    (@mathiasdb)


    Hi

    First of all, your plugin is great but I stumbled upon some issues. ( Or I’m missing some info )

    The hooks ‘reOrder_query_join’, ‘reOrder_query_where’, ‘reOrder_query_orderby’, don’t check by post_type. This alters the SQL for queries where post_types share the same category.

    To solve this, I’ve added some code and a function:
    Inside each of the hooks ‘reOrder_query_join’, ‘reOrder_query_where’, ‘reOrder_query_orderby’; I’ve added an if statement to break the hook.

    if( false == $this->check_if_cpt_is_sortable( $wp_query->get( "post_type" ) ) ) return $args;

    This fail safe uses a function ‘check_if_cpt_is_sortable’, which searches the AdminOptions. The function looks like this:

    public function check_if_cpt_is_sortable( $post_type = '' ) {
    
     //= bail early
     if( empty( $post_type ) ) return false;
    
     //= get admin options
     $options = $this->getAdminOptions();
    
     //= bail; admin options empty
     if( !isset( $options[ 'categories_checked' ] ) ) return false;
    
     //= loop
     foreach( $options[ 'categories_checked' ] as $key => $value ) {
         if( $key == $post_type ) return true;
     }
    
     //= no results return
     return false;
    
    }

    Note: This does only solve enabling / disabling post_types sharing the same category.

    I also stumbled upon another issue, which I didn’t resolve: When enabling multiple post_types sharing the same category. The reorder page show’s all posts shared between that category you want to sort. In my case, this isn’t the desired behaviour. I want to sort the posts per category AND per cpt.

    Anyway, I hope all this information helps some of you.

Viewing 1 replies (of 1 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    thank you for your interest in this plugin,

    First of all, your plugin is great

    please to leave a review when you can.

    The hooks ‘reOrder_query_join’, ‘reOrder_query_where’, ‘reOrder_query_orderby’, don’t check by post_type

    actually there is a verification done on the term id, which is unique and stored for each term that is manually sorted and retried using the line,

                    $orderedSettingOptions = $this->getOrderedCategoriesOptions();
    

    verification of the post type is not a fail-safe check as posts can have several taxonomies associated with them.

Viewing 1 replies (of 1 total)
  • The topic ‘Reorder multiple CPTs with the same category’ is closed to new replies.