This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Sphinx search on outer sql-tables with ajax on wp

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Sphinx search on outer sql-tables with ajax on wp Reply To: Sphinx search on outer sql-tables with ajax on wp

#20549
Ernest MarcinkoErnest Marcinko
Keymaster

Hi Grüsse,

That is possibe by using hook functions. There are a number of filters available before the tokenization process, where you can add additional text as you like. I will list these filters below, you can also find them in the wp-content/plugins/ajax-search-pro/includes/classes/etc/indextable.class.php file:

apply_filters( 'asp_post_content_before_tokenize', $content, $the_post );
apply_filters( 'asp_post_excerpt_before_tokenize', $the_post->post_excerpt, $the_post );
apply_filters( 'asp_post_title_before_tokenize', $the_post->post_title, $the_post );
apply_filters( 'asp_post_permalink_before_tokenize', $the_post->post_name, $the_post );
apply_filters( 'asp_post_custom_field_before_tokenize', $values, $the_post, $field );

As an example, let’s say you want to append additional text to the post content before it’s processed by the keyword tokenizer. Then this code is a good start-off:

add_filter('asp_post_content_before_tokenize', 'my_custom_asp_post_content_before_tokenize', 10, 2);
function my_custom_asp_post_content_before_tokenize($content, $the_post) {
     /**
      * Do your custom queries here, and append the results to the $content variable
      * 
      * More info           
      *   $content is the post content that is tokenized       
      *           
      *   $the_post is the currently processed post object.
      *   The post ID is in $the_post->ID attribute
      **/                 
     return $content;
}