Support » Plugins and Hacks » [Plugin: Limit a post title to X characters] Posts still publish even if title count is too long

[Plugin: Limit a post title to X characters] Posts still publish even if title count is too long

Viewing 13 replies - 1 through 13 (of 13 total)
  • Yep, same thing happening here. You ever resolve your issue?

    I’m curently loocking into this, I think I’ll post an update today resolving this issue!

    (Sorry for long time reply, I though I would have email notifications about theses ! :P)

    Okay, I uploaded a new version to WordPress.org’s repository. It should come up as version 1.1 soon enough. I think I corrected the lines of code that where causing problems. If there is anything that still won’t work, feel free to contact me via the URL provided in the readme file !

    I fixed the “submitting even though under character count” Go to the JS file and attach the check to the submit of the form function, not the button press.

    change the lines here: jQuery(‘#publish’).mousedown(function()

    to this

    if(unCompteur < maximum)
    return true;
    alert(‘You are over the maximum allowed characters for the title!’);
    return false;

    Also, the “settings” link in the plugins list was not working. It had the wrong URL. Change link near // Display a Settings link on the main Plugins page:


    also, apologies if I am submitting this stuff incorrectly, I’m new to wordpress

    Hi, another change in the “submitting even though under character count” post,
    if(unCompteur < maximum)
    if(unCompteur <= maximum)

    for people not that familiar with the file structure, the JS file you need to change is here:


    Hey Mark ! I’ll be looking into this today!

    Hey Mark ! I incorporated your bug fixes in the script (and credited you in the readme), it should update soon today. One thing I didn’t change though is the fact to attach the count check on form submit. If we do that, a jQuery is triggered on WP’s side that shoes a loading icon and makes the button grey. We still can submit again, but it’s confusing, as it’s like the form is submitting, but can’t, while it actually don’t submit at all. That is why the verification is attached to the click. It checks before sending the form and triggering WP’s built in scripts !

    Hi Jean-Philippe,

    I’m glad that you found some of my code useful. re: the loading icon. Yes, I can see your point. I guess the issue is that if we attach to the click event, we don’t intercept the “return” key. So, people can still submit the form, bypassing out character check.

    It’s possible that the loading icon can be overridden via an hook in the PHP. I’ll let you know if I discover anything along those lines.

    Thanks for the great plugin BTW. I really like the character counter on the right side. It’s excellent UI.

    Thank for your comments !

    I shall look into it again soon, let’s keep in touch if you find something before me 🙂


    I did discover another issue: inthe JS, in your docReady function, you assign a keyup “verification_maximum” function to the title field. In this function, you make this assignment unCompteur = jQuery(elemId).val().length. This function works very well for the UI component on the right side.

    The issue is…

    That unCompteur value is used below on the submit click function: if(unCompteur <= maximum).

    The problem is…

    If the user comes to the edit page and does not modify the title (say they are just changing the category), when they click submit, they will get the error that the title is too long (at least, in firefox they do). This happens because unCompteur has not been assigned and evaluates as “undefined” and causes the if statement to render as false.

    the fix is…

    change the if statement in the submit click function as:

    if(jQuery(‘#title’).val().length <= maximum)

    Apologies if you fixed this already!

    Another solution for the issue where if you edit an existing post it incorrectly shows an over-count warning message is to add this line to the lptx-script.js file in the js directory of the plugin:

    Change it from this:

    var i;
    	var maximum = jQuery('#lptx_maximum').val();

    to this:

    var i;
    	var maximum = jQuery('#lptx_maximum').val();
    	i = jQuery('#title').val().length;

    Basically the i variable wasn’t getting set unless you entered text into the #title block. This initializes it on page load with the current value, and the check later on then correctly passes if the value is lower than the maximum allowed.


    Hey everyobdy. Thanks for emailing me and reporting theses bugs.

    I’m curently back from a medical leave, I’ll be updating things soon ! 🙂

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: Limit a post title to X characters] Posts still publish even if title count is too long’ is closed to new replies.