the_editor_content filter change the content of ot

2019-08-05 18:31发布

问题:

I have more then one text areas in wp admin in post add/edit section, i am trying to change the content of by default textarea of wp but when i execute the the_editor_content filter, it change the content of by default textarea but it also change the content of other textareas,is there any way to to change the content of only by default textarea?

Note* Other textareas have different ids

code i used :

add_filter( 'the_editor_content', 'my_editor_content' );
function my_editor_content() {
    global $post;
    return search_keywords($post->post_content, $keyword1,$keyword2,$keyword3);
}

回答1:

I think you need to hook into default_content like this

add_filter( 'default_content', 'my_editor_content' );

function my_editor_content( $content ) {

$content = "This is my default content!";

return $content;
}