add_filter shortcuts in WordPress

Once you start developing more with WordPress you’ll probably find yourself using add_filter to add, modify or remove data.

When modifying some text you might do something like the following simple example.

Sometimes you’ll want to remove text too.

However, you might not be aware (or might forget!) that there’s a shorter way of doing this.

In the above example, there’s no need to write out a separate function to achieve the result that you want. Instead you can use one of the following (self explanatory) ‘shortcut’ functions, baked into WordPress, to pass the type of data that you want.

Writing it out this way is not only shorter, but much easier to read too.

Leave a Reply

Your email address will not be published. Required fields are marked *