• Hello,

    I want to change the perma link on a page theme basis.
    This is what i’ve got so far in my functions.php:

    //Change permalink to subject
    function change_permalink_themebasis( $post ) {
        $template = get_post_meta( $post->ID, '_wp_page_template' ,true );
        if ( 'page-branches.php' == $template) {
            global $wp_rewrite;
         	$wp_rewrite->page_structure = $wp_rewrite->root . 'branches/%pagename%/';
        } elseif ( 'page-modules.php' == $template) {
    	 	global $wp_rewrite;
         	$wp_rewrite->page_structure = $wp_rewrite->root . 'modules/%pagename%/';
    	} else{
    		global $wp_rewrite;
         	$wp_rewrite->page_structure = $wp_rewrite->root . '%pagename%/';
    	}
    }
    add_action( 'add_meta_boxes_page', 'change_permalink_themebasis' );

    It works but the problem is that the front page gives an 404.
    How to fix this? I think the problem is the add_action type “add_meta_boxes_page” but I can’t find the proper one.

Viewing 1 replies (of 1 total)
  • Thread Starter tatof

    (@tatof)

    Oke found out it’s something with the following code:

    $wp_rewrite->page_structure = $wp_rewrite->root . 'branches/%pagename%/';
Viewing 1 replies (of 1 total)
  • The topic ‘wp_rewrite pagetheme – custom Permalink 404’ is closed to new replies.