rel_canonical

Outputs rel=canonical for singular queries.

Description

rel_canonical(); 

Usage

  1. if ( !function_exists( 'rel_canonical' ) ) { 
  2. require_once ABSPATH . WPINC . '/link-template.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = rel_canonical(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/link-template.php  
  1. function rel_canonical() { 
  2. if ( ! is_singular() ) { 
  3. return; 
  4.  
  5.  
  6. if ( 0 === $id ) { 
  7. return; 
  8.  
  9. $url = wp_get_canonical_url( $id ); 
  10.  
  11. if ( ! empty( $url ) ) { 
  12. echo '<link rel="canonical" href="' . esc_url( $url ) . '" />' . "\n";