Forums Forums Search Search Results for 'search_filter_update_post_cache'

Viewing 10 results - 1 through 10 (of 89 total)
  • Author
    Search Results
  • #288948

    Anonymous
    Inactive

    Can i use this Code u posted:

    add_action(‘pmxi_saved_post’, ‘wp_all_import_post_saved’, 1000, 1);

    function wp_all_import_post_saved($id) {
    do_action(‘search_filter_update_post_cache’, $id);
    }

    for updating the cache after import with wpallimport? id i understand that the right way?
    do i have to put the code in the function.php or fuction editor ind wpallimport?

    #272878

    Trevor
    Participant

    This is added to the functions.php file to make sure imported records are indexed by S&F and Relevanssi:

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 1000, 1);
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
        relevanssi_index_doc($id, true, relevanssi_get_custom_fields(), true);
    }

    I am not sure if you are using Relevanssi or not? If not, you don’t need this line:

    relevanssi_index_doc($id, true, relevanssi_get_custom_fields(), true);


    Anonymous
    Inactive

    Hi

    We are using an ACF relationship field that gets updated on the ‘acf/save_post’ hook with the values from another 2 acf relationship fields. It all works and I can see the value in the database, however, for certain relationships (even with the database showing the correct data) we can’t see them in the filter options. The relationship is displayed as a ‘checkbox’ filter, where users can tick it and filter.
    I have tried rebuilding the cache, deleting the meta_key and recreating it (in the acf/save_post hook), clearing the wp_cache_delete of that post, and finally also calling do_action(‘search_filter_update_post_cache’, $post_id); for the post and all the posts in the relationship.

    None of which worked. The only way to make it work, is to remove the relationship, update the post (with removed relationship) and then re-add the relationship and update the post.

    I need some help to understand what is the problem.

    #266664

    Anonymous
    Inactive

    Hello,

    do_action('search_filter_update_post_cache', $post_id); – this clears thee cache of a particular post.
    But how can I rebuilt the cache of a search form (I am talking about the “rebuild cache” option on the search form edit screen) from code?

    Thanks.

    #264356

    In reply to: Cache at time interval


    Trevor
    Participant

    Are you using a plugin like WP All Import to update the posts? If so, you would need this code in your child theme’s functions.php file:

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 1000, 1);
    
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
    }

    If you are also using Relevanssi (a third party text search replacement plugin) and have set the form to use it for text searches, it would need to be this:

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 1000, 1);
    
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
        relevanssi_index_doc($id, true, relevanssi_get_custom_fields(), true);
    }
    #264108

    Trevor
    Participant

    Yes, you will need to follow this guidance:

    https://www.relevanssi.com/knowledge-base/wp-import-compatibility/

    You could probably add just this one line:

    relevanssi_index_doc($id, true, relevanssi_get_custom_fields(), true);

    That’s what I would do, so it would look like this:

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 1000, 1);
    
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
        relevanssi_index_doc($id, true, relevanssi_get_custom_fields(), true);
    }
    #262409

    Trevor
    Participant

    You are using WP All Import Pro. When you use that, it does not inform WordPress (and consequently our plugin) that a post has been changed/created/deleted.

    You need an additional function added to the child theme functions.php file:

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 1000, 1);
    
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
    }

    This is so our cache rebuilds (just for the affected post) after each post is imported. This is the equivalent of editing a post manually and clicking the ‘Update’ button, but much faster.

    #258395

    Anonymous
    Inactive

    Hello there Trevor!

    I’m seeing this issue around, and tried the solutions you gave but it still not work.

    I have imported a custom posts and toxonomies into WordPress with WP All Import. The first time around, the cache building worked, but the other times, the item counts were not accurate in French and they were not updating in the default english language. Rebuilding the cache kept freezing

    Tried to clone, create a new form with regular posts and pages but it does the same.

    I added the function you mentioned with no avail.

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 10, 1);
    
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
    }

    Could you help me out?

    Thank you so much!

    #255933

    Trevor
    Participant

    It has been nearly two years since that old thread, so I would normally recommend you have this in your child theme functions.php file:

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 1000, 1);
    
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
    }

    Which is different from you showed.

    Are you saying that when you import a new post, it gains both of those categories? Or only in our search, but not the actual posts?

    #253958

    Trevor
    Participant

    You would need to add this code to your child theme functions.php file:

    add_action('pmxi_saved_post', 'wp_all_import_post_saved', 1000, 1);
    
    function wp_all_import_post_saved($id) {
        do_action('search_filter_update_post_cache', $id);
    }
Viewing 10 results - 1 through 10 (of 89 total)