How to modify filters in wordpress - WPTRINITY

How to modify filters in wordpress

WordPress Provide the filter hooks to allow plugins to modify various types of internal functionality at runtime.

A functionality can modify function by binding a callback to a filter hook. When the filter is applied, each 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.

Note that $test is passed to the callback, modified, then returned:

function test_callback( $test ) {
    // Maybe modify $example in some way.
    return $example;
add_filter( 'examples_filter', 'test_callback' );

The example below will run when the the_title filter is executed.

function modify_title($title)
return'The modify'. $title. ' with filtered';

add_filter('the_title', 'modify_title');

Filter Parameter :

add_filter() can accept two parameters, First int $priority for the priority given to the callback function, and Second int $accepted_args for the number of arguments that will be passed to the callback function.

function wplms_incourse_quiz_stop_notes($class,$id){
if(get_post_type($id) == 'quiz'){
$class ='in_quiz stop_notes';
return $class;

Leave a Comment

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