Accents in wordpress permalinks

UPDATE: You can find a premium version of this plugin including all accented characters here.

Several weeks ago i had the tough task to find or code a plugin that will let us keep swedish accents in wordpress permalinks. I only found one plugin that does this in the WordPress Plugin Directory, and of course it was not working… I assume it was written for some old version of wordpress. Anyways I started going through some function documentation at the codex and came up with quite simple solution, which will let you keep your language accents in wordpress permalinks.

Use a filter to replace the accents in wordpress permalinks with their UTF8 hex equivalent

I only had to find the proper filter and hook my function there. It worked perfectly below is the code of a MU Plugin for Swedish accents in wordpress permalinks.

Installation:

1) Create a folder named mu-plugins in wp-content and drop the file there. That is pretty much it. The solution will work for all the blogs in your network(if you have a Multi-Site installation)

The code is pretty straight forward but if you have any questions feel free to ask.

IMPORTANT Keep you files UTFed unless you want your editor to strip the characters and mess up your permalinks afterwards. Also keep in mind that this plugin will work only for your new permalinks. Old permalinks will remain intact(you can change them manually if needed).

The example below is for swedish accents in wordpress permalinks and is downloadable as MU-plugin and as a regular plugin as well.

I`m working on uploading it in the WordPress Plugin Directory

<?php
remove_filter( 'sanitize_title', 'sanitize_title_with_dashes');
add_filter( 'sanitize_title', 'restore_raw_title', 9, 3 );
function sweURLtoCHAR($text)
{
$url=array(
"%c3%85","%c3%a5",
"%c3%84","%c3%a4",
"%c3%96","%c3%b6",

);
$char=array(
 "Å","å",
 "Ä","ä",
 "Ö","ö",
);

$str = str_replace($char,$url,$text);
$str_new = str_replace(&quot; &quot;, &quot;&quot;, $str);
return strtolower($str_new);
}
function restore_raw_title( $title, $raw_title, $context ) {
if ( $context == 'save' )
return sweURLtoCHAR($raw_title);
else {
$title_new = str_replace(&quot; &quot;, &quot;&quot;, $title);
return strtolower($title_new);
}
}
?>

In order to use this code snipplet as a regular plugin add the code below at the beginning of your php file

<?php
/*
Plugin Name: Swedish accents in permalinks
Plugin URI: http://awordpress.net/blog/accents-in-wordpress-permalinks/
Description: Allows Swedish accented characters in permalinks
Version: 2.0
Author: Pavel (aka Immortal) Petrov
Author URI: http://www.webbamboo.net
License: GPL2
*/
?>

You can read more about the WordPress standards of creating plugins in the Codex of course.

PS. If you code this use UTF8 without BOM, because otherwise you`ll get “Warning: Cannot modify header information – headers already sent by…”

0  Stars, Based on 0 Reviews

  • http://www.facebook.com/profile.php?id=100003405882132 Ferhat

    I’ve been setting up WordPress since the first veorisn of All in One SEO Pack. You would to use All in One in conjunction with some essential free plugins as a foundation and one or two premium SEO plugins.This is the configuration that I was personally recommended and have been using on my websites ever since with all of them “maintain” #1 #3 rankings on Google for their primary and secondary keywords:All-in-One SEOEasy WP SEOGoogle XML SitemapsSEO Friendly ImagesDagon Sitemap GeneratorPingback Optimizer

    • http://www.facebook.com/profile.php?id=100003406170891 Bill

      I have about 30 blogs on WordPress platforms I would reemmocnd these plugins:Platinum SEOGoogle XML SitemapsW3 Total Cache that should be all you need to get rolling

      • admin

        I`ve been having different problems with W3 Total cache on a WordPress Multisite installed on an OpenVZ VPS…it was actually making the site slower, Google XML Sitemaps(with MultiSite support) also needs a lot of work related to internationalized domain names and sites mapped to a separate domain(and maybe memory optimizations, because I`ve seen it use up to 25MB memory for a single sitemap)….

  • http://www.facebook.com/profile.php?id=100003405877597 Akash

    First, I advice you not to use too many pinulgs. This will affect the performance of your website negative.I use for my wp blogs:All In one SEO PackGoogle XML SitemapsWP Super Cashe

  • http://184.154.31.83/qblog/valorykennedy-blog/entry/quilt-lesson.html my blogger tricks

    Hello I am so excited I found your website, I really found you by accident, while I was looking on Aol for something else, Regardless
    I am here now and would just like to say cheers for a
    tremendous post and a all round entertaining blog (I also love
    the theme/design), I don’t have time to read through it all at the moment but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the awesome job.

  • http://184.154.31.83/qblog/valorykennedy-blog/entry/quilt-lesson.html my article

    Just wish to say your article is as astounding.

    The clearness in your post is simply cool and that i can assume you’re a professional on this subject. Fine along with your permission allow me to grab your feed to keep up to date with drawing close post. Thanks one million and please continue the enjoyable work.

  • http://184.154.31.83/qblog/valorykennedy-blog/entry/quilt-lesson.html my article express reviews

    Hi outstanding blog! Does running a blog similar to this take a lot of
    work? I have absolutely no expertise in programming but I had been hoping to start my own blog soon.
    Anyways, should you have any suggestions or tips for new blog owners please share.
    I understand this is off topic however I simply needed to ask.
    Appreciate it!

    • admin

      Blogging is easier then ever, especially having WordPress around…Solutions for any problems you might stumble upon can easily be found in wordpress forums, stackoverflow, and of course here. If you have any particular
      questions feel free to contact me at contact AT awordpress.net

  • http://annemanning.com/blog/entry/kicking-the-block.html click here button

    Thanks for some other excellent post. The place
    else could anyone get that type of information in such a perfect manner of writing?
    I’ve a presentation next week, and I am at the search for such info.

  • http://esatellitedirectreviews.com/internet-television free online tv

    very good put up, i definitely love this web site, keep on it

  • http://campgear.co.cc Carroll Gilderman

    Hello there! Do you use Twitter? I’d like to follow you if that would be okay. I’m definitely enjoying your blog and look forward to new posts.

    • admin

      I added twitter button to the right menu..I`ll be posting there too from now on :)
      Thanks for the comment!

  • هاست پربازدید,هاست پر ترافیک,طراحی سایت

    My brother suggested I may like this website. He was once totally right. This submit actually made my day. You can not imagine just how much time I had spent for this information! Thank you!

  • Garth

    Thanks. This really helped me out!