Reply To: no wpml search results

#3938

Ernest Marcinko
Keymaster

Hi!

Sorry for the late answer, I've been checking on the second issue, and I needed to ask on wp forums if there is any solution to that from a core developer.

1. I see. Some of the posts doesn't have content, but id does have excerpt. For now you can only select one field, but luckily I have made hook points for this, so a small code snippet can help you out:

add_filter( 'asp_results', 'asp_excerpt_results', 1, 1 );
 
function asp_excerpt_results( $results ) {
  foreach ($results as $k=>$v) {
    // Check the content and the excerpt
    if (($results[$k]->content == null
         || $results[$k]->content == ”
         || strlen($results[$k]->content) < 5)
         && ($results[$k]->excerpt != null
         && $results[$k]->excerpt != ”
         && strlen($results[$k]->excerpt) > 1)
        )
        $results[$k]->content = $results[$k]->excerpt;
  }
  return $results;
}

Try to add this code to your themes functions.php file. I haven't got time to properly test, but it should work.

2. This is lot more complicated unfortunately. The problem is that the override must use internal (wordpress core) functions to retrieve the posts by their id after the ajax search pro does the partial search. The problem with that particular function is, that it cannot retrieve posts from other multisite blogs. (I thought it does) I've contacted a developer to advise me with the issue, so I might be able to work out something.

It will require you to replace 2-3 files, because I will probably need to change a few lines in them. Would you replace those files in the ajax search pro plugin if I attach them here?

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)