WordPress.org

Forums

Limit the Post Size (Not just the Excerpt size) (9 posts)

  1. NathanielElliott
    Member
    Posted 2 years ago #

    Re: My goal is to simply limit the post size on the admin side of the post. I want to limit the entire system to only allow posts that are 300 characters throughout the site. Any ideas on how to do this?

    So, here is my starting point that I've found thus far, now trying to add the same functionality to the "post" area:

    wp-admin/edit-form-advanced.php

    <input type="text" name="post_title" size="30" tabindex="1" value="<?php echo esc_attr( htmlspecialchars( $post->post_title ) ); ?>" id="title" autocomplete="off"
                   onKeyDown= "limitText(this.form.post_title,this.form.countdown,20);"
                   onKeyUp="limitText(this.form.post_title,this.form.countdown,20);"
    />

    wp-admin/js/word-count.js

    function limitText(limitField, limitCount, limitNum) {
    	if (limitField.value.length > limitNum) {
    		limitField.value = limitField.value.substring(0, limitNum);
    	} else {
    		limitCount.value = limitNum - limitField.value.length;
    	}
    }

    Originally from This Great Article!

    But now I want this for the POST area too, ideas?

  2. NathanielElliott
    Member
    Posted 2 years ago #

    I realized I had this question originally in the wrong area, Original Link: Click Here

  3. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    This is done best with your host allowed php init file (discuss with host)

  4. NathanielElliott
    Member
    Posted 2 years ago #

    There isn't a way to limit character count for a post through a theme?

  5. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Post size and character count are two completely different issues. I will be clear now in my reply:

  6. NathanielElliott
    Member
    Posted 2 years ago #

    Seacoast Web Design - Sorry about the confusion!

  7. NathanielElliott
    Member
    Posted 2 years ago #

    Is there a way I could use:

    You have <span id="charsLeft"></span> chars left.
    <textarea id="myTextarea"></textarea>
    <script type="text/javascript">
        $('#myTextarea').limit('140','#charsLeft');
    </script>

    As a jquery way to limit it? An idea a friend Andrew gave me.

  8. Pioneer Valley Web Design
    Member
    Posted 2 years ago #

    Who, please, said to do what and why?

    Never gather code from an unknown and add it to your site, it may include hidden code. Use trusted sources...

  9. NathanielElliott
    Member
    Posted 2 years ago #

    An idea someone sent to me... What do you recommend to do instead?

Topic Closed

This topic has been closed to new replies.

About this Topic