admin管理员组

文章数量:1134587

I have difficulties to make this little code compliant with PHP 8 :

add_filter('excerpt_more', create_function('', 'return "";') );

Any idea how to make it working?

I have difficulties to make this little code compliant with PHP 8 :

add_filter('excerpt_more', create_function('', 'return "";') );

Any idea how to make it working?

Share Improve this question edited Oct 7, 2023 at 22:14 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Oct 7, 2023 at 19:45 Seal20Seal20 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

In general create_function should be replaced with a closure, like this:

add_filter('excerpt_more', function() {
    return "";
});

But in your specific case, you don't even need that. WordPress has you covered already with a built-in function to use in a filter: __return_empty_string(). So you can just write:

add_filter('excerpt_more', '__return_empty_string' );

本文标签: filtersaddfiltercreatefunction pb in PHP8