您应该使用transition_post_status
提交帖子后过滤内容。
在中尝试以下代码functions.php
在您的主题中:
add_action( \'transition_post_status\', \'_new_post\', 10, 3 );
function _new_post( $new_status, $old_status, $post ) {
if ( \'publish\' !== $new_status or \'publish\' === $old_status ) {
return;
}
if ( \'post\' !== $post->post_type ) {
return;
} // restrict the filter to a specific post type
$plain_content = strip_tags( $post->post_content );
$new_post = array(
\'ID\' => $post->ID,
\'post_content\' => $plain_content,
);
wp_update_post( $new_post );
}