Μέγιστο μήκος τίτλου σε άρθρο του Wordpress

Θέλετε να περιορίσετε τον τίτλο των άρθρων του Wordpress ώστε ο συντάκτης να μην χρησιμοποιεί μεγάλους τίτλους και να μην "χαλάει" το layout της σελίδας σας;
Βάλτε τον παρακάτω κώδικα στο functions.php του θέματος που χρησιμοποιείτε (/wp-content/themes/themename/functions.php).
Αλλάξτε το var maxchr = 50; στον επιθυμητό αριθμό γραμμάτων.
Δοκιμάστηκε και λειτουργεί σε Wordpress 3.1.x !

<?php
function jquery4admin() {
    echo
"<script type='text/javascript'>
    // <![CDATA[
    var maxchr = 50;
    jQuery('#title-prompt-text').html('Enter Title Here ('+ maxchr +' characters MAX)');
    jQuery('input#title').keyup( function() {
        if(jQuery(this).val().length > maxchr) { jQuery(this).val(jQuery(this).val().substr(0, maxchr)); }   
    });
    jQuery('input.ptitle').keyup( function() {
        if(jQuery(this).val().length > maxchr) { jQuery(this).val(jQuery(this).val().substr(0, maxchr)); }   
    });
// ]]>
</script>"
;
}
add_action('admin_footer', 'jquery4admin');
?>

Add new comment

Filtered HTML

  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.