Support » Plugin: All in One SEO – Best WordPress SEO Plugin – Easily Improve SEO Rankings & Increase Traffic » Incorrect rel=”canonical” for categorys, tags, acrhives

  • Resolved ikiterder

    (@ikiterder)


    Hi

    Am use plugin

    <?php
    /*
    Plugin Name: Smart Trailing Slash
    Plugin URI: http://www.fastagent.de/res/download/smart-trailing-slash.zip
    Description: Gives permalinks a trailing slash, but removes it in permalinks with a filename extension, e.g. .html
    Version: 1.01
    Author: Peter Claus Lamprecht
    Author URI: http://www.fastagent.de/
    */
    
    function pcl_smart_trailingslashit($string) {
    	/* ensure, that there is one trailing slash */
    	$string = rtrim($string, '/') . '/';
    	/* if there is a filename extension like .html or .php, then remove the trailing slash */
    	if ( 0 < preg_match("#\.[^/]+/$#", $string) ) {
    		$string = rtrim($string, '/');
    	}
    	return $string;
    }
    add_filter('user_trailingslashit', 'pcl_smart_trailingslashit');
    ?>

    Missing slash in rel=cannonical

    How to fix it?

    Sorry for my English.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Arnaud Broes

    (@arnaudbroes)

    @ikiterder You can filter it using this hook – aioseo_canonical_url

    add_filter( 'aioseo_canonical_url', 'aioseo_canonical_url_add_trailing_slash' );
    
    function aioseo_canonical_url_add_trailing_slash( $url ) {
        return trailingslashit( $url );
    }
    Thread Starter ikiterder

    (@ikiterder)

    arnaudbroes
    Thank you . Did it like this

    add_filter( 'aioseo_canonical_url', 'aioseo_canonical_url_add_trailing_slash' );
    
    function aioseo_canonical_url_add_trailing_slash( $url ) {
    	if (  is_archive() ) {
         return trailingslashit( $url );
      }
      return $url;
    }
    Plugin Author Arnaud Broes

    (@arnaudbroes)

    Yeah, that looks good. Awesome!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Incorrect rel=”canonical” for categorys, tags, acrhives’ is closed to new replies.