Last active
October 19, 2016 23:12
-
-
Save vovafeldman/0e00f79e54cf8cbd556683ad64f621b1 to your computer and use it in GitHub Desktop.
Freemius - Changing Search Permastruct
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 | |
/** | |
* Customize docs search permastruct for search caching. | |
* | |
* @author Vova Feldman | |
*/ | |
function freemius_docs_search_permastruct_rewrite() { | |
if ( post_type_exists( 'docs' ) ) { | |
/** | |
* We want the search pages to be cached. | |
*/ | |
add_rewrite_rule( | |
'^help/documentation/search/([^/]+)/?', | |
'index.php?post_type=docs&s=$matches[1]', | |
'top' | |
); | |
} | |
} | |
// The reason we use priority 20, is because this method must be triggered | |
// after `remove_rewrite_rules()` of the docs CPT is called. | |
add_action( 'init', 'freemius_docs_search_permastruct_rewrite', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment