[resolved] How to get clean posts urls (without trailing slash)? (3 posts)

  1. silis25
    Posted 3 years ago #


    1. I want to add canonical link to my blog posts.
    The solution I have found is adding the following:

    <link rel="canonical" href="<?php the_permalink(); ?>"/>

    2. The problem with that solution is that it adds forward-slash '/' at the end of every permalink whereas I want to have the following format:

    <link rel="canonical" href="http://www.letthemstare.com/aventure-dress-giveaway" />

    How can I get posts urls WITHOUT having the forward-slash at the end?

    Thanks and regards,

    Kfir Silis

  2. keesiemeijer
    Posted 3 years ago #

    Why not let a plugin take care of your canonical links? http://wordpress.org/extend/plugins/wordpress-seo/

    You can try it with this but you have to know the post ID:

    <link rel="canonical" href="<?php echo trim(get_permalink($post->ID), '/'); ?>"/>
  3. silis25
    Posted 3 years ago #

    Thanks for your advice, I'll check the plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic