Title: Solution for permalink issue
Last modified: August 7, 2017

---

# Solution for permalink issue

 *  [ultione](https://wordpress.org/support/users/ultione/)
 * (@ultione)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/solution-for-permalink-issue/)
 * I’ve been looking at how to help with the permalink issue with this plugin.
 * One way is for existing users to add this piece of code to your functions.php
   file
 *     ```
       function ontrapage_custom_post_type_mod( $args, $post_type ) {
       	if ( $post_type == "ontrapage" ) {
       		$args['rewrite'] = array( 'slug' => '/' ); 
       	}
       	return $args;
       }
       add_filter( 'register_post_type_args', 'ontrapage_custom_post_type_mod', 10, 2 );
       ```
   
 * This will allow any type of permalink structures you have.
 * For developers of this plugin, please update the way you register the ontrapage
   post type.
    Instead of `'rewrite' => array( 'slug' => 'o' )` change it to `'rewrite'
   => array( 'slug' => '/' )` This will make things so much simpler for what you
   are trying to achieve to make ontrapage custom post type behave like a wordpress
   page. Once this is done, the removeSlug() and interceptRequestTrickery() functions
   can be removed from the plugin.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [ultione](https://wordpress.org/support/users/ultione/)
 * (@ultione)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/solution-for-permalink-issue/#post-9386517)
 * Found a bug in my original solution.
    Please use this code instead
 *     ```
       function ontrapage_custom_post_type_mod( $args, $post_type ) {
       	if ( $post_type == "ontrapage" ) {
       		$args['rewrite'] = array( 'slug' => '/', 'with_front' => false );
       	}
   
       	return $args;
       }
       add_filter( 'register_post_type_args', 'ontrapage_custom_post_type_mod', 10, 2 );
       ```
   
 * And for the plugin developer
    `'rewrite' => array( 'slug' => '/', 'with_front'
   => false )`
 * Once the plugin is updated, the additional code to functions.php will not be 
   required. If left alone, will not cause any issues either.
 *  Thread Starter [ultione](https://wordpress.org/support/users/ultione/)
 * (@ultione)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/solution-for-permalink-issue/#post-9386522)
 * One thing to add, for users, once you have added the code to your functions.php
   Make sure that you flush your permalinks.
    Go to Settings > Permalinks and press
   save changes to refresh.
 *  Thread Starter [ultione](https://wordpress.org/support/users/ultione/)
 * (@ultione)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/solution-for-permalink-issue/#post-9386565)
 * Sorry to get everyone’s hopes up.
    The solution will fix the permalink issue 
   for ontrapages but will stuff up normal wordpress pages.
 * So please DELETE this solution. Thanks.
 *  Thread Starter [ultione](https://wordpress.org/support/users/ultione/)
 * (@ultione)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/solution-for-permalink-issue/#post-9387478)
 * I’ve managed to rework the solution for a possible workaround.
    Add below code
   to functions.php. And flush your permalink settings (Go to Settings > Permalinks
   and press save changes to refresh)
 *     ```
       function ontrapage_custom_post_type_mod( $args, $post_type ) {
       	if ( $post_type == "ontrapage" ) {
       		$args['rewrite'] = array( 'slug' => 'o', 'with_front' => false ); //set url so that it does not show anything in front
       	}
   
       	return $args;
       }
       add_filter( 'register_post_type_args', 'ontrapage_custom_post_type_mod', 10, 2 );
   
       function add_ontrapage_custom_rewrite() {
       	add_rewrite_rule('([^/]+)(?:/([0-9]+))?/?$', 'index.php?ontrapage=$matches[1]&page=$matches[2]', 'bottom');
       }
       add_action( 'init', 'add_ontrapage_custom_rewrite' );
       ```
   
 * This was tested on a permalink structure of /blog/%postname%
 *  [ontraportfrank](https://wordpress.org/support/users/ontraportfrank/)
 * (@ontraportfrank)
 * [8 years, 8 months ago](https://wordpress.org/support/topic/solution-for-permalink-issue/#post-9387829)
 * Everyone is free to try this solution, but as with any custom coded solution,
   it is not supported by ONTRAPORT.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Solution for permalink issue’ is closed to new replies.

 * ![](https://ps.w.org/ontrapages/assets/icon-256x256.png?rev=1987352)
 * [ONTRApages](https://wordpress.org/plugins/ontrapages/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ontrapages/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ontrapages/)
 * [Active Topics](https://wordpress.org/support/plugin/ontrapages/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ontrapages/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ontrapages/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [ontraportfrank](https://wordpress.org/support/users/ontraportfrank/)
 * Last activity: [8 years, 8 months ago](https://wordpress.org/support/topic/solution-for-permalink-issue/#post-9387829)
 * Status: not resolved