Home › Forums › Programming › Deprecated: Function create_function() is deprecated – WordPress
Post PHP 7.2 version upgrade, my php script in WodPress throwing an error as mentioned below.
Line Thrown the Error:
add_action('widgets_init', create_function('', 'return register_widget("music_post_widget");'));
Deprecated: Function create_function() is deprecated in /folder/file.php on 2
I think create_function() is deprecated in PHP 7.2 version.
create_function method is deprecated in Php v7.2. So you have to make your code compatible with Php version greater than 7.2.
Good news is that there is an easy solution for this.
Replace your below line
function sampleFunction ()
add_action ('widgets_init', 'sampleFunction ');
music_post_widget is the word you have to copy from the line 1.
Mail (will not be published) (required):
Enter the destination URL
Or link to existing content