Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Check if you have revisions enabled and not limited. Some post types may have a lot of metadata and when a revision is created, all get duplicated.

    Thread Starter greenya

    (@greenya)

    Just updated to 5.0.2 and it seems all is working fine now.

    Thank you!

    After investigating the source of the plugin and wp_terms table, I can see that it actually saves the order, but issue comes with filtering get_terms, when plugin try to sort terms and return them in correct order. The issue i that term->term_order it uses is incorrect, the WP fills it with other values, not the ones the plugin expects.

    I came up with the following fix. Basically, it does a SQL query to order given term IDs in the proper order.

    VER: 3.1.3
    FILE: intuitive-custom-post-order.php
    LINE: 757; replace 2 lines 757 (“usort…”) and 758 (“return…”) with the following block:

    // ------------------------------------------------
    // PATCH: Fix issue with incorrect term_order
    // ------------------------------------------------
    // usort( $terms, array( $this, 'taxcmp' ) );
    // return $terms;
    // ------------------------------------------------
    if (count($terms) < 2) {
        return $terms;
    }
    
    global $wpdb;
    
    $db_result = $wpdb->get_results("
        SELECT term_id
        FROM $wpdb->terms
        WHERE term_id in (" . join(',', array_map(function ($t) { return $t->term_id; }, $terms)) . ")
        ORDER BY term_order
    ", output: ARRAY_N);
    
    if (is_array($db_result)) {
        $ordered_ids = array_map(function ($e) { return intval($e[0]); }, $db_result);
        $terms_map = [];
        foreach ($terms as $t) { $terms_map[$t->term_id] = $t; }
        return array_map(function ($id) use ($terms_map) { return $terms_map[$id]; }, $ordered_ids);
    } else {
        usort( $terms, array( $this, 'taxcmp' ) );
        return $terms;
    }
    // ------------------------------------------------
    // END OF PATCH
    // ------------------------------------------------

    @hijiri please take a look at this patch, do your changes and add fix to this awesome plugin. Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)