Created
October 22, 2018 05:36
-
-
Save msaari/71a3fd752a9bc5d7efd8b2ae6967d910 to your computer and use it in GitHub Desktop.
Index slugs for Relevanssi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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