Skip to content

Instantly share code, notes, and snippets.

@vovafeldman
Last active October 27, 2021 14:05
Show Gist options
  • Save vovafeldman/6d4ddd83a8e38fcc9fd912781f02139c to your computer and use it in GitHub Desktop.
Save vovafeldman/6d4ddd83a8e38fcc9fd912781f02139c to your computer and use it in GitHub Desktop.
Freemius - weDocs Permalinks
<?php
/**
* Customize docs permalinks parsing.
*
* @author Vova Feldman
*/
function freemius_docs_permastruct_rewrite() {
if ( post_type_exists( 'docs' ) ) {
// Modify root slug to "help" instead of docs.
global $wp_post_types;
/**
* @var WP_Post_Type $docs
*/
$docs = $wp_post_types['docs'];
$docs->remove_rewrite_rules();
$docs->rewrite['slug'] = 'help';
$docs->add_rewrite_rules();
add_post_type_support( 'docs', 'excerpt' );
add_post_type_support( 'docs', 'author' );
add_post_type_support( 'docs', 'page-attributes' );
add_post_type_support( 'docs', 'custom-fields' );
}
}
add_action( 'init', 'freemius_docs_permastruct_rewrite' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment