Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Cache not updated automatically

Viewing 10 posts - 1 through 10 (of 27 total)
  • hamren
    #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 Moderator
    #87318

    If 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.

    hamren
    #88487

    Hello 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.

    Trevor Moderator
    #88500
    This reply has been marked as private.
    hamren
    #88825
    This reply has been marked as private.
    Ross Moderator
    #89240
    This reply has been marked as private.
    hamren
    #89668
    This reply has been marked as private.
    Ross Moderator
    #90520

    Hi Sanna

    I’m hoping to have an update to this thu evening, if not friday.

    Best

    Ross Moderator
    #91340
    This reply has been marked as private.
    hamren
    #92746
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 27 total)

The topic ‘Cache not updated automatically’ is closed to new replies.