[wp-trac] [WordPress Trac] #36034: Change post name permalinks to use ID when inserting links
    WordPress Trac 
    noreply at wordpress.org
       
    Tue Mar  1 21:34:04 UTC 2016
    
    
  
#36034: Change post name permalinks to use ID when inserting links
-------------------------+-----------------------------
 Reporter:  catchmyfame  |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  trunk
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 When using the visual editor, and your permalink setting is postname, the
 default behavior when adding an internal link is that the href attribute
 points to the slug. For example, if I add a link to a page with the
 permalink/slug of "my-page" the HTML link will be created as `<a
 href="http://example.com/my-page/>my page</a>`.
 This is fine until the slug of the target page (`my-page`) changes. Since
 WordPress doesn't do any checking when a slug is changed to see if there
 are any links pointing to it, the link is now dead. I propose that when
 adding links in the visual editor, that they be added based on the ID of
 the target, not the slug. This would prevent links from breaking whenever
 a slug was changed, and not affect the use of the post name in the URL.
 Even following ID-based links return the prettier post name version in the
 URL.
 The code change is already available as a plugin or addition to
 functions.php from http://wordpress.stackexchange.com/questions/156032
 /how-can-i-store-page-id-in-a-post-instead-of-other-selected-permalink:
 {{{
 function wp_link_query_mod ( $results ){
     if( count( $results ) ){
         for( $i=0; $i<count($results); $i++ ){
             $results[$i]['permalink'] = wp_get_shortlink(
 $results[$i]['ID'] );
         }
     }
     return $results;
 }
 add_filter('wp_link_query', 'wp_link_query_mod');
 }}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36034>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
    
    
More information about the wp-trac
mailing list