[wp-hackers] Trailingslashit to re_canonical

Dan Gayle dangayle at gmail.com
Fri Apr 9 16:54:42 UTC 2010


I don't know how to submit patches or requests to WP, but this is an
easy fix that I hope someone can add. Since every link is redirected
to a slashed version in the function redirect_canonical, every
canonical url output via rel_canonical should have a slash also.

from wp-includes/link-template.php

2132  /**
2133   * Output rel=canonical for singular queries
2134   *
2135   * @package WordPress
2136   * @since 2.9.0
2137  */
2138  function rel_canonical() {
2139      if ( !is_singular() )
2140          return;
2141
2142      global $wp_the_query;
2143      if ( !$id = $wp_the_query->get_queried_object_id() )
2144          return;
2145
2146      $link = get_permalink( $id );
2147      echo "<link rel='canonical' href='$link' />\n";
2148  }


Modify line 2146 to:
2146      $link = trailingslashit(get_permalink( $id ));


More information about the wp-hackers mailing list