假设我有这样一个函数:
function cc_get_content_preview() {
return apply_filters( \'cc_get_content_preview\', get_the_excerpt(), 55 );
}
在这里get_the_excerpt()
是$value
我可以在add_filter
对的问题:如您所见,第二个参数apply_filters
(get_the_excerpt()
), 不是变量。在add_filter
作用如下所示($cctoreturn)
:
//Set custom content preview for Aff posts
function cc_custom_content_preview($cctoreturn){
$post_id = get_the_ID();
if (is_sticky($post_id)) :
$cctoreturn = $post_id;
endif;
return $cctoreturn;
}
add_filter( \'cc_get_content_preview\', \'cc_custom_content_preview\', 20, 1);