Did you ever figure this out? I would love to know how to do this!!!
Save this code as a php file – I called it compact-slug.php – and drop into the plugin folder
<?php
/*
Plugin Name: Compact Slug
Description: This plugin adds a function that condenses spaces in a slug instead of replacing them with a dash.
Version: 1.0
Author: Shaun Flagg
License: GPL2
*/
function generateSlug($slug)
{
$slug = strtolower($slug);
$slug = preg_replace('/&.+?;/', '', $slug); // kill entities
$slug = str_replace('.', '-', $slug);
$slug = preg_replace('/[^%a-z0-9_-]/', '', $slug);
$slug = preg_replace('/\s/', '', $slug);
$slug = preg_replace('|-+|', '-', $slug);
$slug = trim($slug, '-');
return $slug;
}
remove_filter('sanitize_title', 'sanitize_title_with_dashes');
add_filter('sanitize_title','generateSlug');
?>
}
Hi,
Reset your desired permalink from wordpress admin area and add this code in htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Now, check with blog posts and pages.
Thanks,
Shane G.