Yoast SEO
How to exclude canonical URL on two pages? (1 post)

  1. roundaboutmv
    Posted 3 years ago #

    We have a bunch of dynamic URLs (they are real estate property listings) that are not being indexed by Google because of the canonical. From this forum I found out how to exclude it on the "Rentals" page but what is the correct syntax to exclude it from a second page? In this case, the "Sales" page?

    I'm assuming there's might be "array" involved, but so far everything I've tried has broken it. Here's the original code -

    of function wpseo_canonical_exclude( $canonical ) {
    global $post;
    if ( $post->ID == xxx) {
    $canonical = false;
    return $canonical;
    add_filter( 'wpseo_canonical', 'wpseo_canonical_exclude' );


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.