Search code examples
wordpresspermalinks

Add base to permalink


Added 'custom structure' for premalink and placed '/mybase/%postname%/'

It is making all posts look like 'www.mysite.com/mybase/postname'

But it is not working for pages.

page name still remains 'www.mysite.com/pagename'.

How to change it ?


Solution

  • Put this code in your functions.php file.

    add_action( 'init', 'custom_page_rules' );
    
    function custom_page_rules() {
        global $wp_rewrite;
        $wp_rewrite->page_structure = $wp_rewrite->root . '/mybase/%pagename%'; 
    }
    

    After put this code you want to save permalink once time in wordpress back end.