Support Forums

Hey there, it looks like you've been redirected from designsandcode.com - as you can see we have a new home - read more

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

Forums Forums Search & Filter Pro new posts are not showing in search results

Viewing 10 posts - 1 through 10 (of 18 total)
  • dann hanks
    #145709

    Hi, I have a really odd problem with search and filter results.

    My site allows users to upload a custom post ‘property’.

    When they upload the property, it will not show in the search and filter results. It’s odd as the internal search of the website finds it as soon as it’s published. Logging in as admin shows the property post that they have uploaded as published, it just wont display in search and filter results.

    I have noticed also that if I log in as admin and edit their post slightly and update it, shows up on the results, for some reason S&F does not like my users posts.

    any help will be great.

    Trevor Moderator
    #145729

    The tool that you use to upload the post requires a extra bit of code to trigger the adding of it to our cache.

    You can see the documentation here:

    https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Update_Cache_for_a_Particular_Post

    dann hanks
    #145785

    Hi Trevor,

    thanks for that, I note this is for a particular post though – I would need it to cover all posts that users upload… Is that possible? Perhaps by the custom post type?

    : )

    Dann

    Trevor Moderator
    #145791

    Most post importers tend to use a function to do the import, and that function usually returns the post ID of the new post. You can feed that in to a PHP variable, and then use that instead of the number.

    dann hanks
    #145795

    mmm… I will have to have a delve around and test..

    is there no way to add this to functions.php? I don’t really want to have to hack my plugin.

    Trevor Moderator
    #145797

    It is possible IF the author of the importer has provided a filter hook to allow this. You would need to contact them for advice.

    dann hanks
    #145818

    Hi,

    I have found the point where the posts are being created, it is done with acf_form (advanced custom fields).

    here is the point of creation:

     
    
    acf_form(array(
    		'post_id'		=> 'new_post',
    		'post_title'	=> true,
    		'post_content'	=> true,
    		'html_submit_spinner'	=> '<span class="acf-spinner"></span>',
    						'fields' => array(
    						'field_58cbdee51e676', 'field_59275314be48d', 'field_58cbdea81e675', 'field_592761f1f5089', 'field_58cc419adc979', 'field_58cbdf351e677', 'field_58cc4030d72ed' , 'field_58cbe07a1e67f', 'field_58cbe4815ba98', 'field_58cbe4385ba97', 'field_58cbe4255ba96', 'field_5927621af508a', 'field_58f9fb4b79b0f', 'field_5926bf6634841', 'field_5926b208b9016', 'field_58c02d04898e2', 'field_58c02e471efe3', 'field_58c02ec61e011', 'field_592eb6f95b95b'
    	),
    		'new_post'		=> array(
    		'post_type'		=> 'property',
    			'post_status'	=> 'publish'
    		),
    		'return'		=> home_url('my-account/?profile=all-post'),
    		'submit_value'	=> 'Create Property'
    		
    	));
    

    is this where I would add the “do_action(‘search_filter_update_post_cache’, xx);”?

    sorry, a little out of my depth here…

    thanks!

    Trevor Moderator
    #145820

    Ah. ACF. we have done a lot of digging with that before. See this post:

    https://support.searchandfilter.com/forums/topic/cache-not-updated-automatically/page/2/#post-94346

    dann hanks
    #146253

    Hi Trevor, thanks for pointing me to here, however the fix did not work. I am not sure if I have missed something though, all I have done here is add

    function my_acf_save_post( $post_id ) {
        
    	// bail early if no ACF data
    	if( empty($_POST['acf']) ) {
    		return;        
    	}
    	
    	if ((!is_admin()) || (defined('DOING_AJAX') && DOING_AJAX)) {
    		do_action("search_filter_update_post_cache", $post_id);
    	}    
    }
    
    add_action('acf/save_post', 'my_acf_save_post', 20);

    to my functions file… I have tried to backtrack through this thread to see if something is missing. There are many private messages though so it’s difficult to tell.

    Trevor Moderator
    #146272
    This reply has been marked as private.
Viewing 10 posts - 1 through 10 (of 18 total)

You must be logged in to reply to this topic.