user3424298
user3424298

Reputation:

When to use add_action vs add_filter?

It seems cleaner to make a plugin and use add_action -- why would you use add_filter?

Upvotes: 0

Views: 264

Answers (1)

Prakash Rao
Prakash Rao

Reputation: 2398

add_filter hook is mainly used to change the content before displaying it ..

Suppose I want to print the title as bold when I use the_title() function of WordPress. So to modify this function only in terms of display, we can use add_filters.

Example : add_filter( 'the_title', function( $title ) { return '<b>' . $title . '</b>'; } );

Upvotes: 1

Related Questions