Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以使用函数自动删除 [shortcode] 和 $content of post 中的简码内容?我希望作者只能放置文本,而不是代码或简码。
谢谢
您需要挂钩wp_insert_post_data。
PHP:
function remove_shortcodes( $data , $postarr ){ $data['post_content'] = strip_shortcodes( $data['post_content'] ); return $data; } add_filter( 'wp_insert_post_data', 'remove_shortcodes', '99', 2 );
参考: