user3087089
user3087089

Reputation:

What is difference between these Wordpress filter hooks

I'm new to WordPress plugin development. I have a doubt about below 3 filter hooks.

Upvotes: 1

Views: 352

Answers (1)

bnp887
bnp887

Reputation: 5746

content_edit_pre filter hook

The content_edit_pre filter hook is used to hook into the content of a post just before it is loaded to be edited. For example, if you included the following at the end of your functions file:

function test_of_content_edit_pre( $content, $post_id ) {
    return "Insert this before the content about to be edited ".$content;
}
add_filter( 'content_edit_pre', 'test_of_content_edit_pre', 10, 2 );

Then open a post to edit it, you would see that the text has been inserted before the post:

content edit pre example

excerpt_edit_pre filter hook

The excerpt_edit_pre filter hook is very similar to content_edit_pre, except it is used to hook into excerpts (instead of posts) just before they are loaded to be edited. For example:

function test_of_excerpt_edit_pre( $content, $post_id ) {
    return "Add this to excerpt".$content;
}
add_filter( 'excerpt_edit_pre', 'test_of_excerpt_edit_pre', 11, 2 );

Would result in this being shown in the excerpt:

excerpt after filter hook

content_filtered_edit_pre filter hook

This one I am not sure about. I tested it out and it didn't seem to do anything. I will update my answer if I can find more information on this.

Upvotes: 2

Related Questions