0
votes

Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given in C:\xampp\htdocs\marine\wordpress\wp-content\plugins\timber-library\lib\Twig.php on line 268 I keep getting this on my WordPress theme Homepage. Am using Timber wordpress for developing WordPress themes.

I installed Timber via installing the plugin on WordPress admin. The actual behavior: Everything appears as it should, because i haven't started the hooking the posts. This is just from adding my html css js and images from my designer. I've only worked on the header and footer and Menu. Nothing has been tinkered on from the back-end PHP files. I am using (WordPress version 4.7.3) PHP 5.6.30 on xampp, Timber 1.2.4

emphasized text

1
Can you find out more specifically where that happens? Can you comment out different parts of your Twig files and see which part might trigger that warning? - Gchtr
@Gchtr I've commented the return call on line 268 and this $twig->addFunction(new \Twig_SimpleFunction('action', function( $context ) { $args = func_get_args(); array_shift($args); $args[] = $context; call_user_func_array('do_action', $args); }, array('needs_context' => true))); - joe_88
Thanks alot did wonders @Gchtr - joe_88
Yes, maybe it did wonders, but you shouldn’t edit any files in the Timber plugin, because as soon as you update the plugin, the error will be there again. With "Twig files", I didn’t mean the Twig.php file, but all your files in your theme with a .twig extension. The warning is probably thrown by an error in your theme, so you should first find the part in your theme that’s causing the warning. - Gchtr

1 Answers

0
votes

I just had this same error, and googling brought me here, so just wanted to share what worked for me. I got this error trying to check a wordpress function using fn() in the twig template.

The thing I missed that caused this error was putting the function name in single quotes. Once I added those, the error went away.

{% if fn('wp_is_mobile') %}

There's also the possibility that what you're calling in the fn() isn't defined in php either, so check where you're defining the if it's a custom one.