Forums › Forums › Search & Filter Pro › Programmatically Rebuild Cache
- This topic has 13 replies, 3 voices, and was last updated 9 years, 5 months ago by
Trevor.
-
Ross Moderator(Private) October 24, 2016 at 6:03 pm #65988
Hey Paddy
Why not perform a ajax request to to trigger the rebuild? I think that you would need to be in the admin area for it to work though.
Alternatively, you can try to do this manually, you would need the class located in
search-filter-pro/includes/class-search-filter-post-cache.phpYou’d probably just need to init the class –
$sf_cache = new Search_Filter_Post_Cache();Then run the function:
$sf_cache->cache_restart();The function will also start processing the first batch of posts too if
wp_remote_postis not working in your environment – so this may cause it to take considerable time to complete (ie, a few seconds, possibly more depending on your environment)That being said, this class wasn’t made to be dev friendly at this stage, although looking at it it should just work – be aware of possible changes in future releases where class names and functions may be changed.
Thanks
Anonymous(Private) October 24, 2016 at 11:22 pm #66152Hi Ross,
That looks great! I will test that out, but if what you said is true about the class names changing in the future, then I’d like to ask maybe there’s another way to what I am really trying to achieve?
What I am actually doing is:
1. Delete all posts.
2. Delete all S&F cache.
3. Start adding posts one at a time inside a loop. While adding a single post, I am also usingdo_action('search_filter_update_post_cache', $new_post_id);to generate the new cache as the script proceeds to adding each posts.So if it’s okay to rephrase my question a little bit, is there a way for me to “Empty” the cache instead?
By the way. Thanks for the helpful warning!
-
AuthorPosts