Home / comment / Duplicate content comment pages
  • How to Duplicate content comment pages

    no thumbnail sorry: Duplicate content comment pages

    Adding this PHP code to the functions.php of your wordpress theme will prevent duplicated content as a result of multiple comments pages.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    function canonical_for_comments() {
    	global $cpage, $post;
    	if ( $cpage > 1 ) :
    		echo "\n";
    	  	echo "<link rel='canonical' href='";
    	  	echo get_permalink( $post->ID );
    	  	echo "' />\n";
    	 endif;
    }
    add_action( 'wp_head', 'canonical_for_comments' );
    

    ( WordPress codex functions, hooks, in this snippet. )

    wp_head, get_permalink, add_action, wp,