• Resolved John

    (@dsl225)


    Hi folks,

    I was wondering whether this has been implemented in the meanwhile since this ticket and if not whether it is recommended adding it manually or with an SEO plugin for instance.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor manuelge

    (@khaztiel)

    Hi John,

    This feature is not available in the current version of WPeMatico or its addons, however you can add it manually to the functions.php file of your theme.

    Then you have to assign a category to the campaign and use the slug of that category in the filter, replacing the text “category-slug” in filter.

    After this, the posts created by WPeMatico and assigned to that category will have the rel=”canonical” to the sourcesite, you can check it in the source code of each post.

    
    add_action( 'wp_head', 'etruel_add_meta_tag', 0 );
    function etruel_add_meta_tag() {
    	global $post;
    	$post_id = $post->ID;
    	$post_permalink = get_permalink( $post_id, false );
    	
    	$wpe_campaignid = get_post_meta( $post_id, 'wpe_campaignid', true );
    	$wpe_sourcepermalink = get_post_meta( $post_id, 'wpe_sourcepermalink', true );
    
    	if (has_category('category-slug',$post->ID)){
    		remove_action('wp_head', 'rel_canonical');
    		echo '<link rel="canonical" href="'.$wpe_sourcepermalink.'" />';
    	}
    }
    

    Regards,
    Manuel

    Thread Starter John

    (@dsl225)

    Many thanks for your feedback Manuel, well noted!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is rel=canonical implemented?’ is closed to new replies.