Skip to content

Instantly share code, notes, and snippets.

@vovafeldman
Last active October 19, 2016 23:12
Show Gist options
  • Save vovafeldman/0e00f79e54cf8cbd556683ad64f621b1 to your computer and use it in GitHub Desktop.
Save vovafeldman/0e00f79e54cf8cbd556683ad64f621b1 to your computer and use it in GitHub Desktop.
Freemius - Changing Search Permastruct
<?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