Support » Fixing WordPress » %postname%: removing the dashes

  • Hi,

    Is there a way that i can remove the dashes in my permalink %postname& structure? So that:

    Hello World Test Post



    instead of



Viewing 3 replies - 1 through 3 (of 3 total)
  • 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

    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');


    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]
    # END WordPress

    Now, check with blog posts and pages.


    Shane G.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘%postname%: removing the dashes’ is closed to new replies.