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

Exclude numbers from index

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Exclude numbers from index

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #55296
    shop_aZynshop_aZyn
    Participant

    Hi there,

    how can I exclude numbers or some special characters (such as “%”, “$” etc.) from index?

    Sebastian

    #55299
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi Sebastian,

    Special characters are automatically trimmed during indexing.

    Excluding numerical strings from the index is only possible via a custom code:

    add_filter( 'asp_indexing_keywords', function( array $keywords ) {
    	foreach ( $keywords as $keyword => $data ) {
    		if ( is_numeric($keyword) ) {
    			unset($keywords[$keyword]);
    		}
    	}
    	return $keywords;
    });

    Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    After adding the custom code a new index needs to be generated so the numerical values are excluded.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.