WordPress at a glance
function is not described

rel_canonical() WP 2.9.0

Outputs rel=canonical for singular queries.

  • Since 4.6.0 Adjusted to use wp_get_canonical_url().

No Hooks.

Return

Nothing (null).

Usage

rel_canonical();

Code of rel canonical: wp-includes/link-template.php VER 5.1.1

<?php
function rel_canonical() {
	if ( ! is_singular() ) {
		return;
	}

	$id = get_queried_object_id();

	if ( 0 === $id ) {
		return;
	}

	$url = wp_get_canonical_url( $id );

	if ( ! empty( $url ) ) {
		echo '<link rel="canonical" href="' . esc_url( $url ) . '" />' . "\n";
	}
}