I suspect this bug is in newer versions of the code too.
Essentially a new feature was introduced in version 4 "Automatic post slugs will only include 5 words by default -- but you can always manually enter your own and longer slug"
When creating a new blog post you enter a title. The title updates the slug as you type. So if my title is "This is a very long wordy title" then the slug is updated to "This is a very long wordy title", but when I save the blog it is mangled to "this-is-a-very-long". I then have to go back and update the slug and delete the old one. I could edit the slug after I have typed the title manually replacing all the spaces and punctuation with minuses, but this is a pain and I sometimes forget.
I suppose the bug here is that the JavaScript fills the slug automatically with incorrect data that you are supposed to change later rather than filling it up with correct data that you don't have to change. I also disagree with your magic number of 5 words as I thing that Google uses all of them along with all the stuff in the page for its SEO calculation.
So can we have a backend option like $g_slug_word_length
defaulting to 5 but zero means keep all my words. As an easy workaround (for me) I have implemented it in JavaScript on the frontend. It was over complicated by the slug_changed option so I've stripped it all out!
Here is the diff:
--- inc/items/model/_item.funcs-original.php 2015-01-30 13:24:02.483624200 +0000
+++ inc/items/model/_item.funcs.php 2015-01-30 13:23:28.442799192 +0000
@@ -2171,19 +2171,14 @@
{
?>
<script type="text/javascript">
- var slug_changed = false;
jQuery( '#post_title' ).keyup( function()
{
- if(!slug_changed)
- {
- jQuery( '#post_urltitle' ).val( jQuery( '#post_title' ).val() );
- }
- } );
-
- jQuery( '#post_urltitle' ).change( function()
- {
- slug_changed = true;
- jQuery( '[name=slug_changed]' ).val( 1 );
+ var t_title = jQuery( '#post_title' ).val().toLowerCase();
+ t_title = t_title.replace(/[^a-z0-9]/g, "-");
+ t_title = t_title.replace("--", "-");
+ t_title = t_title.replace(/^-/, "");
+ t_title = t_title.replace(/-$/, "");
+ jQuery( '#post_urltitle' ).val( t_title );
} );
</script>
<?php
Hi @davidnewcomb,
There is a parameter in the backend to set the word count of the slugs: http://b2evolution.net/man/single-post-pages-seo. Maybe the idea of set this value to 0 in order to keep all the words in the slug could be a good improvement. In the meantime, you can use a large number (i.e. 100).
Regards!