Skip to content

Instantly share code, notes, and snippets.

@msaari
Created October 22, 2018 05:36
Show Gist options
  • Select an option

  • Save msaari/71a3fd752a9bc5d7efd8b2ae6967d910 to your computer and use it in GitHub Desktop.

Select an option

Save msaari/71a3fd752a9bc5d7efd8b2ae6967d910 to your computer and use it in GitHub Desktop.
Index slugs for Relevanssi
<?php
/**
* Adds the post slug to the post content, with dashes replaced with spaces.
* Add this to theme functions.php and rebuild the index.
*
* @param string $content The additional post content.
* @param object $post The post object.
*/
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment