admin管理员组

文章数量:1125747

this maybe a stupid question, when I’m trying to create a custom filter to hook into later and filter and return something, I don’t get any results. I am testing this in the themes functions.php

//value to filter
$message = 'Hello this is a message I want to filter in WP.';

//create my custom filter
apply_filters('message_filter', $message);

add_filter('message_filter', 'change_message');

// define the callback function you mentioned in the above filter function
function change_message($message){
    
    $message = str_replace("Hello","Hi",$message);
    
    return $message;
}

I don't see anything returned in the browser.

本文标签: