验证WordPress中的帖子标题和内容

I intend to let users create blog posts via the front end. I need to make sure the post title and content are each less than 100 characters.

Which hook should I hook my validation function to?

Thanks in advance.

Try this:

Use plugin for that. It will help you needful.

Refer this: http://wordpress.org/plugins/post-title-validation/

OR

Use this code.

add_action( 'admin_notices', 'custom_error_notice' );
function custom_error_notice(){
    global $current_screen, $post;
    if ( $current_screen->parent_base == 'edit' ){
        if((!$post->post_name && !$post_content) && $_GET['post']) {
            wp_redirect(admin_url('post-new.php?empty=1'));
        }
        if($_GET['empty']) echo '<div class="error"><p>Warning - Please fill up all fields correctly!</p></div>';
    }
}
  • Thanks