wordpress add post validation wordpress add post validation wordpress wordpress

wordpress add post validation


It's not a bug, WordPress intentionally do this (to save revisions AFAIK). anyways, this may work but could be better ways than this (paste in your functions.php file)

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->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>';    }}

Also, this is required to use wp_redirect and to avoid header already sent error message, paste this in your functions.php at the top of all other code

function callback($buffer) {    // You can modify $buffer here, and then return the updated code    return $buffer;}function buffer_start() { ob_start("callback"); }function buffer_end() { ob_end_flush(); }// Add hooks for output bufferingadd_action('init', 'buffer_start');add_action('wp_footer', 'buffer_end');


Well, You are right, WordPress don't have validation in Post Edit Screen,

Why don't you try Post require Fields plugin, Where you can easily Check What to validate, You don't require to write single line of code of javascript or PHP.

Here is screenshot for Backend Management

enter image description here