Search code examples
facebookfacebook-commentscanonical-link

Prevent Facebook from loading comments from the canonical url?


I have a Facebook comments plugin loading comments for URLs on example.com (e.g. example.com/sample-post), but it is loading comments for the rel=canonical link that is specified in the page head.

Is there any way to prevent this or force Facebook to load comments from example.com/sample-post?


Solution

  • As @CBroe suggested, updating the og:url fixed this issue, while still keeping canonical intact!

    In case anyone here runs into this issue when using The SEO Framework, working code was:

    add_filter( 'the_seo_framework_ogurl_output', function( $url, $id ) {
    
      if ( is_singular() ) {
          // Change singular URL here.
          $url = get_permalink();
      } else {
          // Change term/taxonomy URL here.
      }
    
      return $url;
    }, 10, 2 );
    

    Thank you!