Created
October 22, 2018 04:35
-
-
Save msaari/3b8593939600b49d59e5d8c4de65d098 to your computer and use it in GitHub Desktop.
Index post 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