fatal error: call to undefined function wp_headers() - wordpress

I get error like call to undefined function wp_headers() in wp_content in my theme folder.
how to solve this error?

You should be more specific with your error message, but likely you mean to use wp_head() and not wp_headers() in your header.php file.
A good place to start with learning theme development is here: http://codex.wordpress.org/Theme_Development

Related

Fatal error: Call to undefined function add_action() in

I am trying to add action in a plugin in a file which is included to the base php plugin file:
add_action( 'wp_ajax_my_action', 'my_action' );
Then I am requiring the file in the main plugin file:
require_once plugin_dir_url(__FILE__) . 'api/index.php';
, but I am getting this error:
Fatal error: Call to undefined function add_action() in
This code works fine, if it is in the main plugin file, but if I put it in another file it doesn't.
I have followed some answers to similar questions to include wp-load, but I am getting the same error.
Following this code, I think you might solve your issue.
// You must define the wp_ajax_my_action callback
function my_action( $my_action_callback ) {
// Write your action
};
// add the action
add_action( 'wp_ajax_my_action', 'my_action');
If you want to get more info, please refer to http://hookr.io/actions/wp_ajax_my_action/
Good luck!

Parsing Meteor error: Exception from Deps afterFlush

I get these Deps errors from time to time and I can never figure out what they mean or what they're pointing to:
Exception from Deps afterFlush function function: SyntaxError: Unexpected identifier
at eval (native)
at http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:372:22
at Function.jQuery.extend.globalEval (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:373:7)
at jQuery.ajaxSetup.converters.text script (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9806:11)
at ajaxConvert (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:8873:18)
at done (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9293:15)
at callback (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9753:8)
at Object.send (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9759:7)
at Function.jQuery.extend.ajax (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9244:15)
at Function.jQuery._evalUrl (http://localhost:4000/packages/jquery.js?265926494aaa3929cd2e30da265211c5929f37a4:9409:16) debug.js:41
It thinks that there is a syntax error, but the only files it points to are jquery.js, which I HIGHLY doubt contain errors...
This error is caused by code in a Template helper somewhere that uses JQuery/a jquery plugin and is running code using eval which contains a syntax error in it, which is why it appears to come from JQuery itself.
There isn't much more than this to go off im afraid. It might be from ajax. Have a look at your chrome's network tab to see what is being downloaded just before this happens and see if it contains any javascript.
If it contains HTML when it should contain javascript check your Meteor paths, Meteor does not throw 404 errors, instead it serves out the main page's html, which may be why the error displays this way instead of a 404
I just came across the similar "afterFlush" error, and while my error was also rooted in a jQuery/plugin with Meteor, it had nothing to do with eval.
The issue circled back around to updating the DOM at the same time I was updating a reactive method, where Meteor was also updating the DOM reactively. I found this out, and removed the manual DOM manipulation, which made this error go away. Hope someone else finds this helpful...

Wordpress error when sending comment

I'm using the default comments template, on my own self-built theme. When I send a comment I get the following error message:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wp_set_comment_cookies' not found or invalid function name in /home/mattator/public_html/wp-includes/plugin.php on line 403
Warning: Cannot modify header information - headers already sent by (output started at /home/mattator/public_html/wp-includes/plugin.php:403) in /home/mattator/public_html/wp-includes/pluggable.php on line 881
couldn't find a call to the funciton 'wp_set_comment_cookies' anywhere in the code. It is noteworthy that despite the error message the comment is being sent properly. I also tried to disable all plugins but the problem persists.
Any ideas would be appreciated.
May be you have some extra white space before
<?php
tag in starting of a theme file
Thanks
Well, I experimented a little bit, and as turns out the problem was a call to the function "nocache_headers()", in Line 18 of the file "wp-comments-post.php" which lies at WP root directory.
I deleted it, and voila, everything works. Not sure why though.

PHP Warning/Error on Wordpress Site

I'm getting this warning message on a Wordpress I have just setup:
http://wptest.paddingtonterraces.com.au/
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'gllr_add_script' was given in /home/paddingt/public_html/wptest/wp-includes/plugin.php on line 403
Anyone know how to sort this one out?
Deactive your plugins and theme and activate them one by one so you will find out which component causes the problem or which plugin does the function comes from.
It's looking for a function named gllr_add_script... does that function exist?

Missing includes in Wordpress plugin (wp_insert_post function)

I created a code which generates content and I want to populate Wordpress's database with it. I am using wp_insert_post and add_post_meta functions but every time I load which triggers the script I get this error:
Fatal error: Call to undefined function add_action() in \www\scriptmafia\wp-includes\post.php on line 153
To my mind it due to some missing includes. I have included post.php which it mentioned as required include for wp_insert_post function.
I know this is pretty common among newbies in WordPress. However, any solution I have tried have not worked for me.
require_once( ABSPATH . '/wp-load.php'); should solve it :)

Resources