Created
December 12, 2016 12:32
-
-
Save rayrutjes/d56f30fa0a094700e2149ca2b8e58b6d to your computer and use it in GitHub Desktop.
This gist is useful for the Algolia plugin for WordPress when the backend URL is different from the frontend URL. Here we replace the `cms.` subdomain with the `www.` subdomain. After integrating this snippet in your code, you should trigger a full re-index.
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 | |
| /** | |
| * @param array $shared_attributes | |
| * | |
| * @return array | |
| */ | |
| function custom_post_shared_attributes( array $shared_attributes ) { | |
| $shared_attributes['permalink'] = str_replace( 'cms.', 'www.', $shared_attributes['permalink'] ); | |
| return $shared_attributes; | |
| } | |
| add_filter( 'algolia_post_shared_attributes', 'custom_post_shared_attributes' ); | |
| add_filter( 'algolia_searchable_post_shared_attributes', 'custom_post_shared_attributes' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment