[wp-trac] [WordPress Trac] #4652: Page and category trailing back-slash dependent on post permalink structure

WordPress Trac wp-trac at lists.automattic.com
Thu Jul 19 01:11:36 GMT 2007


#4652: Page and category trailing back-slash dependent on post permalink structure
-----------------------+----------------------------------------------------
 Reporter:  snakefoot  |       Owner:  anonymous 
     Type:  defect     |      Status:  new       
 Priority:  high       |   Milestone:  2.2.2     
Component:  General    |     Version:  2.2       
 Severity:  major      |    Keywords:  wp_rewrite
-----------------------+----------------------------------------------------
 If specifying a post permalink structure like this:

 /article/%postname%.html

 Then WP_Rewrite will discover that there is no ending back-slash and will
 set use_trailing_slashes to false.

 Whenever creating links to categories og pages then it will now remove the
 ending back-slash.

 This changes all category and page links when upgrading from 2.0 to 2.2,
 with duplicate content to follow.

 The quick patch to this problem is to create a plugin with the following
 lines:

 {{{
 <?php
 function fix_trailing_backslash() {
   global $wp_rewrite;
   $wp_rewrite->use_trailing_slashes = true;
 }

 function fix_trailing_backslash_post( $link ) {
   global $wp_rewrite;
   if (!substr($wp_rewrite->permalink_structure, -1, 1) == '/' ))
     return rtrim( $link, '/' );
   return $link;
 }

 add_action('init', 'fix_trailing_backslash');
 add_filter('post_link', 'fix_trailing_backslash_post' );
 ?>
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/4652>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list