In WordPress, Every post will be assigned with unique URL called “Slug”. If you didn’t manually edit it, Slug is automatically assigned to your post depending on the permalinks settings and post title.

Mostly we all are in so much rush that we forget to check Slug before publishing, So words like a, in, or, and from your post title makes the url longer, unreadable and less SEO friendly. Things go much worse when your post title is really longer [Check Androidpolice for instance]

According to Matt Cutts (Popular figure in SEO industry), Google bots won’t be having problem reading shorter and descriptive urls while longer urls makes it less SEO friendly because Google will give more weight to keywords at the beginning.

If you have got a three, four or five words in your URL, that can be perfectly normal. As it gets a little longer, then it starts to look a little worse. Now, our algorithms typically will just weight those words less and just not give you as much credit.

So how to make post URL short and SEO Friendly in an Automatic way. Yes, Codes.

Method 1

Lets say you like to remove all words which has less than three letters, Such as a, an, or, in etc. Add the following code at the end of  your current theme’s functions.php file

add_filter('sanitize_title', 'remove_short_words');
function remove_short_words($slug) {
    if (!is_admin()) return $slug;
    $slug = explode('-', $slug);
    foreach ($slug as $k => $word) {
        if (strlen($word) < 3) {
    return implode('-', $slug);

If you like to go more aggressive like eliminating all three letter words then just change the line 6 of the above code with desired letter count (increase it by one).

if (strlen($word) < 4) {

Method 2

Previously we eliminated words according to its letter count but you can do it more efficiently by adding a dictionary which contains list of words to eliminate from URL. Add the following code to functions.php file as you did earlier

add_filter('sanitize_title', 'remove_false_words');
function remove_false_words($slug) {
	if (!is_admin()) return $slug;
	$slug = explode('-', $slug);
	foreach ($slug as $k => $word) {
		//false words list separated for commas
		$keys_false = 'a,about,above,across,after,again,against,all,almost,alone,along,already,also';
		$keys = explode(',', $keys_false);
		foreach ($keys as $l => $wordfalse) {
			if ($word==$wordfalse) {
	return implode('-', $slug);

In line 7 of the above code you can find the list of words which are blacklisted. You can add more words by separating each words with comma. For example lets add words like and and in to the list

$keys_false = 'a,about,above,across,after,again,against,all,almost,alone,along,already,also,and,in';

This method is bit safest and efficient because words like “against”, “already” contains more than five letters and if you decide to eliminate all five letter words then you may end up eliminating keywords also. Its little pain in the ass to add those words but its worth the pain.

Now Read : How to Display Custom Avatar in Comments For Users Without Gravatar

Download : Copyblogger 2 – Free Genesis 2 Child Theme (HTML5 and CSS3) [updated]

Thanks to wpmu and Kevin Chard for this useful code snippet.


  1. says


    Nice post! i really love the coding stuff. Both the methods are really nice and worth trying.Changing url structure is a risk process since it may effect seo of our blog. So we must do it in right way,

    thanks for sharing.

  2. says

    Hey Vivek,
    Very helpful topic indeed, and i am convinced this is a must apply thing for any blog, however i don’t understand the difference between the two methods as i am not a programmer and know little about coding,
    can you please point out or show us a step by step tutorial on how to implement this and where to add the code ??
    or is there any good plugin that you can perform this action ?
    Many thanks and Best wishes!
    Mitch recently posted…Free CV Builder, Free Resume Builder, cv templatesMy Profile

  3. says

    Grate post Vivek :) It is nice to hear to short WordPress Post URL for more reachable and SEO friendly. Hope this will also affects my new blog as well i.e.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge