You appear to be a bot. Output may be restricted
Description
Calculate and return the canonical URL.
Usage
$null|string = genesis_canonical_url();
Parameters
Returns
null|string The canonical URL if one exists, null
otherwise.
Source
File name: genesis/lib/functions/general.php
Lines:
1 to 67 of 67
function genesis_canonical_url() { global $wp_query; $canonical = ''; $paged = (int) get_query_var( 'paged' ); $page = (int) get_query_var( 'page' ); if ( is_front_page() ) { if ( $paged ) { $canonical = get_pagenum_link( $paged ); } else { $canonical = trailingslashit( home_url() ); } } if ( is_singular() ) { $numpages = substr_count( $wp_query->post->post_content, '<!--nextpage-->' ) + 1; $id = $wp_query->get_queried_object_id(); if ( ! $id ) { return null; } $cf = genesis_get_custom_field( '_genesis_canonical_uri' ); if ( $cf ) { $canonical = $cf; } elseif ( $numpages > 1 && $page > 1 ) { $canonical = genesis_paged_post_url( $page, $id ); } else { $canonical = get_permalink( $id ); } } if ( is_category() || is_tag() || is_tax() ) { $id = $wp_query->get_queried_object_id(); if ( ! $id ) { return null; } $taxonomy = $wp_query->queried_object->taxonomy; $canonical = $paged ? get_pagenum_link( $paged ) : get_term_link( (int) $id, $taxonomy ); } if ( is_author() ) { $id = $wp_query->get_queried_object_id(); if ( ! $id ) { return null; } $canonical = $paged ? get_pagenum_link( $paged ) : get_author_posts_url( $id ); } if ( is_search() ) { $canonical = get_search_link(); } return apply_filters( 'genesis_canonical_url', $canonical ); }