空帖标题WordPress

有没有一种方法可以检查帖子标题是否为空, 然后, 如果帖子标题为空, 则自动将该帖子设置为草稿或隐藏在前端?我知道有一个插件https://wordpress.org/plugins/post-title-validation/, 但是我不能选择。有什么办法可以做到这一点?

喜欢:


#1


wp_insert_post_data过滤器可以做到这一点:

add_filter( 'wp_insert_post_data' , 'filter_post_data' , '99', 2 );
function filter_post_data( $data , $postarr ) {
    // Change post status if empty post title
    if( empty($data['post_title']) ) {
      $data['post_status'] = 'draft';
    }
    return $data;
}

#2


我发现键入</>也可以。

来源:

https://www.srcmini02.com/62997.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_42036.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?