Title: Give page theme custom Permalink 404
Last modified: August 30, 2016

---

# Give page theme custom Permalink 404

 *  [tatof](https://wordpress.org/support/users/tatof/)
 * (@tatof)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/give-page-theme-custom-permalink/)
 * 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.

Viewing 1 replies (of 1 total)

 *  Thread Starter [tatof](https://wordpress.org/support/users/tatof/)
 * (@tatof)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/give-page-theme-custom-permalink/#post-6285968)
 * 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 ‘Give page theme custom Permalink 404’ is closed to new replies.

## Tags

 * [permalink](https://wordpress.org/support/topic-tag/permalink/)
 * [slug](https://wordpress.org/support/topic-tag/slug/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [tatof](https://wordpress.org/support/users/tatof/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/give-page-theme-custom-permalink/#post-6285968)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
