Skip to content

Instantly share code, notes, and snippets.

@mmarj
Forked from vovafeldman/functions.php
Created October 27, 2021 14:05
Show Gist options
  • Save mmarj/2cb1de91606dc2e5e81ec946bc915fe9 to your computer and use it in GitHub Desktop.
Save mmarj/2cb1de91606dc2e5e81ec946bc915fe9 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