What is: Filters in wordpress

,




Filters are functions, it's allow developers modify the default behavior of a specific function.

So developers easily to modify default WordPress filters and actions and even create their own custom filters based on her theme or plugins.

Filters are different than Actions. WordPress actions are executed at events like when a theme or plugin is activated, or when a post is published. Filters are used to filter output when it is sent to either database or to user browser.

Example of using a WordPress filter

function wpb_custom_excerpt( $output ) {
  if ( has_excerpt() && ! is_attachment() ) {
    $output .= wpb_continue_reading_link();
  }
  return $output;
}
add_filter( 'get_the_excerpt', 'wpb_custom_excerpt' );

The sample code above adds a function wpb_custom_excerpt to the filter get_the_excerpt.





Related Post


Latest Post


Recent Posts Widget

Make sure to never miss a thing...

Get the latest news from the creative industry along with other creative goodies, conveniently delivered to social media.