我在管理端有一些自定义JavaScript,用于统计帖子,另一个用于检查是否勾选了复选框。
$(\'.inside input\').on(\'click\', function() { 
        if ($(this).is(\':checked\')) {
        console.log(\'checked\');
            $(\'#title\').val(\'overview\');
        } else {
            $(\'#title\').val(title);
        }
    });
 另一个
$(\'#postexcerpt\').find(\'textarea\').on(\'keyup\', function(e) {
        max_chars = 240 - $(this).val().length;
        if (max_chars < 1) {
            $(this).val($(this).val().substr(0,238));
        }
        $(\'#counterbox\').html(max_chars);
    });
 上述代码正常工作。我的问题是,当我保存帖子、CPT或任何其他帖子类型时,标题字段不会保存?有什么想法吗?
更新-保存CPT
add_action(\'save_post\',\'save_press_meta\');
 函数save\\u press\\u meta(){全局$post;$post\\u id=$post->id;
if( defined( \'DOING_AUTOSAVE\' ) && DOING_AUTOSAVE ) return;
    if( isset( $_POST[\'paper\'] ) )  
    update_post_meta( $post_id, \'paper\',$_POST[\'paper\']);
    if( isset( $_POST[\'press_article_thumbnail\'] ) )  
    update_post_meta( $post_id, \'articlethumbnail\',$_POST[\'press_article_thumbnail\']);
    if( isset( $_POST[\'press_article_content\'] ) )  
    update_post_meta( $post_id, \'articlecontent\',$_POST[\'press_article_content\']);      
    if( isset( $_POST[\'press_article_pubtime\'] ) )  
    update_post_meta( $post_id, \'articlepubtime\',$_POST[\'press_article_pubtime\']);      
 }