Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

add_filter()

3 tags 1 category

add_filter() — Adds a callback function to a filter hook. WordPress offers filter hooks to allow plugins to modify various types of internal data at runtime. A plugin can modify data by binding a callback to a filter hook. When the filter is later applied, each bound callback is run in order of priority, and given the opportunity to modify a value by returning a new value. The following example shows how a callback function is bound to a filter hook. Note that $example is passed to the callback, (maybe) modified, then returned: function example_callback( $example ) { // Maybe modify $example in some way.

Inputs: $hook_name (string): The name of the filter to add the callback to. $callback (callable): The callback to be run when the filter is applied. $priority (int): Optional. Used to specify the order in which the functions associated with a particular filter are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the filter. Default 10. $accepted_args (int): Optional. The number of arguments the function accepts. Default 1.

Returns true: Always returns true.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…