[wp-trac] [WordPress Trac] #40227: shortlink shows POST instead of PAGE guid

WordPress Trac noreply at wordpress.org
Tue Mar 21 23:26:15 UTC 2017


#40227: shortlink shows POST instead of PAGE guid
--------------------------+-----------------------------
 Reporter:  Darko A7      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.7.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 original forum topic is here:
 https://wordpress.org/support/topic/shows-post-url-form-instead-for-page/

 In short: created "page" inside WP Admin > Pages menu, and in it's source
 code the shortlink displayed is wrong (using form for posts, instead of
 pages):

 wrong:

 {{{
 <link rel='shortlink' href='https://mywebsite.com/?p=995' />
 }}}

 correct:
 {{{
 <link rel='shortlink' href='https://mywebsite.com/?page_id=995' />
 }}}

 proposed fix:
 https://wordpress.org/support/reply/8941661/

 original code:

 {{{
 if ( 'page' === $post->post_type && $post->ID == get_option(
 'page_on_front' ) && 'page' == get_option( 'show_on_front' ) ) {
 $shortlink = home_url( '/' );
 }}}


 should be:


 {{{
 if ( 'page' === $post->post_type ) {
 $shortlink = home_url( '?page_id=' . $post_id );
 }}}

 No longer get 404 from the shortlink url @ page's source code.

 Thanks!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40227>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list