• We use memcache on our sites (https://www.ads-software.com/extend/plugins/memcached/), and this plugin’s update calls do not clear the caches for the updated posts, so when editing the post later, the menu_order is still listed as the old field from the cache. This can be easily solved by adding a call to clean_post_cache( $post_id ); after each update call.

    From 1ca7fd5fe71d72ca1fa5569493745fac96c5a246 Mon Sep 17 00:00:00 2001
    From: Kevin
    Date: Wed, 8 Feb 2017 15:21:46 -0600
    Subject: [PATCH] clean post caches

    …/plugins/simple-custom-post-order/simple-custom-post-order.php | 3 +++
    1 file changed, 3 insertions(+)

    diff –git a/wp/wp-content/plugins/simple-custom-post-order/simple-custom-post-order.php b/wp/wp-content/plugins/simple-custom-post-order/simple-custom-post-order.php
    index bdaa62d..bd8ea43 100644
    — a/wp/wp-content/plugins/simple-custom-post-order/simple-custom-post-order.php
    +++ b/wp/wp-content/plugins/simple-custom-post-order/simple-custom-post-order.php
    @@ -124,6 +124,7 @@ class SCPO_Engine {
    “);
    foreach ($results as $key => $result) {
    $wpdb->update($wpdb->posts, array(‘menu_order’ => $key + 1), array(‘ID’ => $result->ID));
    + clean_post_cache($result->ID);
    }
    }
    }
    @@ -181,6 +182,7 @@ class SCPO_Engine {
    foreach ($data as $key => $values) {
    foreach ($values as $position => $id) {
    $wpdb->update($wpdb->posts, array(‘menu_order’ => $menu_order_arr[$position]), array(‘ID’ => intval($id)));
    + clean_post_cache($id);
    }
    }
    }
    @@ -260,6 +262,7 @@ class SCPO_Engine {
    }
    foreach ($results as $key => $result) {
    $wpdb->update($wpdb->posts, array(‘menu_order’ => $key + 1), array(‘ID’ => $result->ID));
    + clean_post_cache($result->ID);
    }
    }
    }

    2.10.1 (Apple Git-78)

  • The topic ‘Clear Post Cache after Reordering’ is closed to new replies.