[wp-trac] [WordPress Trac] #36198: wp_shortlink_wp_head should exit on non-singles and frontpage

WordPress Trac noreply at wordpress.org
Thu Mar 10 18:47:52 UTC 2016


#36198: wp_shortlink_wp_head should exit on non-singles and frontpage
-----------------------------+-----------------------------
 Reporter:  andrejcremoznik  |      Owner:
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Permalinks       |    Version:  4.4.2
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 There is no need for shortlinks on archives and front page.

 The default function which outputs shortlink markup should check if the
 displayed content is a single post or page but not a static front page
 before outputting anything.

 This is what I use instead of the default `wp_shortlink_wp_head`.


 {{{
 function print_shortlink() {
     $shortlink = wp_get_shortlink(0, 'query');
     if (empty($shortlink) || is_front_page() || (!is_single() &&
 !is_page()))
       return;
     echo "<link rel='shortlink' href='" . esc_url($shortlink) . "'>\n";
   }
 }
 }}}

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


More information about the wp-trac mailing list