Forums › Forums › Search & Filter Pro › Cache not updated automatically
- This topic has 26 replies, 4 voices, and was last updated 7 years, 8 months ago by Ross.
-
Anonymous(Private) January 31, 2017 at 9:45 pm #87228
It seems I have a problem with cache not rebuilding automatically. New posts are not included in the search results unless I edit them or manually rebuild the cache.
I’ve read in the forum that I can use the (for example)
do_action('search_filter_update_post_cache', 23);
to update a single post, but I don’t know how/when to call it. I’m using ACF front-end form to create posts. I can’t figure out how to get the id of the created posts.My ACF form code looks like this:
acf_form(array ( 'post_id' => 'new_post', 'new_post' => array( 'post_type' => 'report', 'post_title' => 'Report', 'post_status' => 'publish', ), 'field_groups' => array (412), 'submit_value' => 'Report', 'return' => '/thanks' )); ?>
Please let me know how to solve this issue. Are there any alternatives to perform the action mentioned for all new posts?
Trevor(Private) February 1, 2017 at 10:53 am #87318If you are following the ACF documentation to do this, you should have
acf_form_head();
on the page as well?I am not sure from reading the documentation, but I think that this may be returning the post ID of the saved post. Maybe.
So, change
acf_form_head();
to$saved_post_id = acf_form_head();
and try to echo that
$saved_post_id
variable to the page to see if it does indeed return the saved post ID. If it does, you can use that variable.Anonymous(Private) February 7, 2017 at 2:26 pm #88487Hello again,
Thank you for your answer. I have now changed form page template from using
acf_form_head();
to$saved_post_id = acf_form_head();
. I change the form itself to return the post that is created. It now looks like this:<?php acf_form(array ( 'post_id' => 'new_post', 'new_post' => array( 'post_type' => 'report', 'post_title' => 'Report', 'post_status' => 'publish', ), 'field_groups' => array (412), 'submit_value' => 'Report', 'return' => '%post_url%' )); ?>
On the page (“single-report”) that this returns on submit, I print the ID using this code:
<?php echo get_the_ID(); ?> <?php do_action('search_filter_update_post_cache', get_the_ID()); ?>
…and that works fine but that does not solve the problem. The post is not automatically added to the filtered result. Can you please point me in the right direction now?
I forgot to mention that the theme I use is Avada (5.0.5), don’t know if that could have any impact on this issue.
I’ve been in contact with the ACF-support and their answer is as follows:
The issue sounds like the “Search and Filter Pro” plugin is not being notified that a new post is created. ACF uses all the WP functions to save the new post, but it is possible that this plugin is only running in the admin (not on the front end). I would contact the “Search and Filter Pro” plugin devs and ask them about the compatibility with posts being created from the front end.
Ross Moderator(Private) February 16, 2017 at 4:10 am #90520Hi Sanna
I’m hoping to have an update to this thu evening, if not friday.
Best
-
AuthorPosts