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?
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.
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?
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:
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
We also use cookies to store items in your cart as well as allowing your to login on the site.
You can adjust all of your cookie settings by navigating the tabs on the left hand side.
By continuing to use this site, you also agree to our Privacy Policy.
Strictly Necessary Cookies
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
*Other cookies used for logging in and cart functions will only be used when you use those features and cannot be disabled.
If you disable these cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
3rd Party Cookies
This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
Please enable Strictly Necessary Cookies first so that we can save your preferences!