Canonical URLs without using a WordPress Plugin

Below is the code that you need to add within the head of your theme template:


 


You need to replace kiwideas.com with your domain.

Adding canonical Links in WordPress

Below are a few easy steps that have you up and running with WordPress canonical URLS in no time at all, and without a plugin.

   Login to WordPress
    Hover over Appearance
    Click Editor
    Find Theme Header (header.php)
    Add the Universal PHP Code for Canonical URLS found above within the HEAD section of your theme header file.

Universal PHP Code for Canonical URLS

Other example for experts

 
  <?php
 $link = str_replace('content/', '', $_SERVER['REQUEST_URI']);
 $linkstring = str_replace(' ','',$link ); 
 ?> 

     <link rel="canonical" href="https://recetas1.com<?php echo $linkstring;?>">

canonicalwordpresswithoutplugin

5/5 - (10 votes)