c0wfunk

Events Calendar Canonical URL Fix

Feb 15th, 2012
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1.  
  2. remove_action( 'wp_head', 'rel_canonical' );
  3.  
  4. add_action( 'wp_head', 'custom_rel_canonical', 10, 0 );
  5. function custom_rel_canonical() {
  6.  
  7. $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
  8.  
  9. if( tribe_is_month() || tribe_is_upcoming() || tribe_is_past() ) {
  10. echo "<link rel='canonical' href='" . esc_url( $url, 'canonical' ) . "' />\n";
  11. }
  12. else {
  13. rel_canonical();
  14. }
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment