WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Archives
Remove trailing slash (6 posts)

  1. gazpachu
    Member
    Posted 3 years ago #

    How can I remove the trailing slash?

    Thanks

  2. jmzolezzi
    Member
    Posted 2 years ago #

    I would like to know this as well.

  3. Codepress
    Member
    Posted 2 years ago #

    You can use this untrailingslashit($url). It will remove any trailing slashes.

  4. jmzolezzi
    Member
    Posted 2 years ago #

    Thanks for your reply @codepress.

    Any hints on how to use that function globally? I'm not sure how to use it.

  5. Codepress
    Member
    Posted 2 years ago #

    You can remove the trailing slash globally by going to "Settings > Permalinks", and set your own custom structure without the trailingslash.

    For the generated links inside your theme you could try the following - this will remove trailingslashes for links that have been generated by the the_permalink() function for posts and pages.

    function permalink_untrailingslashit($link) {
    	return untrailingslashit($link);
    }
    add_filter('page_link', 'permalink_untrailingslashit');
    add_filter('post_type_link', 'permalink_untrailingslashit');
  6. jmzolezzi
    Member
    Posted 2 years ago #

    You are right codepress, thanks.

    In my case, configuring the permalinks accordingly and disabling Custom permalinks allowed me to accomplish this.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic