Skip to main contentSkip to footer

By default, Relevanssi does not index the post slug. It is, however, an easy thing to fix using the relevanssi_content_to_index filter hook. This function will read the post slug, replace the hyphens with spaces (so that indexing-post-slugs becomes “indexing post slugs”) and add the slug to the post content.

Add this function to your site and rebuild the index to see it in effect.

add_filter( 'relevanssi_content_to_index', 'rlv_index_slug', 10, 2 );
function rlv_index_slug( $content, $post ) {
    $slug_with_spaces = str_replace( '-', ' ', $post->post_name );
    return $content . ' ' . $slug_with_spaces;
}

Your account

Not logged in. Log in to see your license details.

Search

Popular Resources

Simple French plurals

If you have Relevanssi Premium and want to make Relevanssi understand French plurals, you can add this code to your site: add_filter( ‘relevanssi_stemmer’, ‘relevanssi_french_plural_stemmer’ ); function relevanssi_french_plural_stemmer( $term ) { $len = strlen( $term ); $end1 = substr( $term, -1, 1 ); if ( ‘s’ === $end1 && $len >…

Ordering search results by date
I’m building a directory and would like the oldest posts to automatically display first in the search results, is this…

Related Posts:

Comment Section:

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed