Answers for "wordpress required post admin title field"

0

wordpress required post admin title field

/** ADD Validation for title */
    function force_post_title_init()
{
    wp_enqueue_script('jquery');
}
function force_post_title()
{
    echo "<script type='text/javascript'>\n";
    echo "
  jQuery('#publish').click(function(){
        var testervar = jQuery('[id^=\"titlediv\"]')
        .find('#title');
        if (testervar.val().length < 1)
        {
            jQuery('[id^=\"titlediv\"]').css('border', '2px solid red');
            alert('Post title is required');
            return false;
        }
    });
  ";
    echo "</script>\n";
}
add_action('admin_init', 'force_post_title_init');
add_action('edit_form_advanced', 'force_post_title');
add_action('edit_page_form', 'force_post_title');
Posted by: Guest on March-03-2021

Code answers related to "wordpress required post admin title field"

Browse Popular Code Answers by Language