Support » Plugins » Hacks » need some help with %postname% issue

Viewing 15 replies - 1 through 15 (of 23 total)
  • right below to post title on page edit is the permalink which can be edited.
    it can be adjusted there after the title has been set.

    But generally I would avoid this. Searchengines prefer dashes instead of one long word as long as you don`t set a full sentence as the permalink.
    As far as I remember max. 4-5 dashes per url is ok.

    Not what I’m looking for I know how to use the regular wordpress. I want this to be done automatically without editing.

    I would of thought that but I made that slug page and it did nothing. Unless he’s just not very clear what files get what and only posted brief to where someone would need to know how to code well to do it.

    I mean they put something in there coding somewhere so it does it automatically. There has to be a way to reverse the coding they did to make it look like a normal website url.

    Moderator bcworkz


    The code posted in gerald’s link works as advertised, at least on my installation, perhaps you misunderstood how to use this?

    (Disregard the .htaccess post, not sure what that’s about, it appears to be a misdirected response.)

    The code is a very simple plugin. You could also add the code to a child theme’s functions.php or add it to an existing plugin code you’ve authored.

    To use it as a separate plugin as the author suggested, create a folder in your plugins folder called “compact-slug”. In that folder, create a new file named “compact-slug.php”. Place the posted code in this new file. To avoid “unexpected output” warning messages, delete everything below the add_filter(... line.

    Log on to your site as an administrator and activate the “Compact Slug” plugin. All new post slugs will not have dashes nor spaces.

    Worked like a charm is there any way to get the actual page title to have no spaces once posted as well. This way anyone else makes a post the title will appear without any spaces?

    sorry I mean post title not page title in the above comments.

    Moderator bcworkz


    You can add this code to where ever you put the other code:

    add_filter('wp_insert_post_data', function ( $data ) {
    	$data['post_title'] = generateSlug( $data['post_title']);
    	return $data;

    If you still want a mixed case title, you’ll need another version of generateSlug() that does not use the strtolower($slug) function.

    I will try adding it. I just want the url and pot title to both not have a dash or space between them at all. Just one long word.

    Parse error: syntax error, unexpected T_FUNCTION in my compact-slug.php file.

    Guess what I mean is the url is fixed perfect now how to fix the post title itself

    Adams Garage = How it is now.

    AdamsGarage = How I want the post title to show as.

    Moderator bcworkz


    Unexpected T_FUNCTION means there’s a missing parenthesis, bracket, semi-colon, etc. somewhere at or above the location specified. I did test the snippet before posting it, and once again just now. It ran without error each time.

    My above snippet as is will result in a title of “adamsgarage” using your example, all lowercase, no spaces. This occurs when the post is published or updated. As mentioned above, if you want the title to be CamelCase, you need to copy the generateSlug() function definition, rename it, remove the $slug = strtolower($slug); line, and call the renamed revised function instead of generateSlug().

    where is this going and how does the final code look?

    I’m very new to wordpress and have no clue where to add this coding and what is going away. Is it a new file or something?

    am i adding your code just anywhere to the compact-slug file? or was there a set place it needed to go and replace something there.

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘need some help with %postname% issue’ is closed to new replies.