本文介绍了致命错误:调用未定义函数add_action()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了一些有关Twitter更新的代码-
i got some code for twitter updates-
function twitit() {
global $wp_query;
$thePostName = $wp_query->post->post_name;
echo '<div id="twitit"><a href="http://twitter.com/home?status=Currently reading '.$thePostName.' : '.get_permalink($post->ID).'" title="Click to send this page to Twitter!" target="_blank">Share on Twitter</a></div>';
}
function widget_twitit($args) {
extract($args);
echo $before_widget;
echo $before_title;
echo $after_title;
twitit();
echo $after_widget;
}
function twitit_init() {
register_sidebar_widget(__('Twit It'), 'widget_twitit');
}
add_action("plugins_loaded", "twitit_init"); //line 30
?>
致命错误:在第30行的C:\ xampp \ htdocs \ shizin \ twitter.php中调用未定义的函数add_action()
推荐答案
只需在其他功能之前添加require(dirname(__FILE__) . '/wp-load.php');
行.这应该可以解决您的问题.
Just add the line require(dirname(__FILE__) . '/wp-load.php');
before the other functions. This should solve your problem.
记住dirname(__FILE__)
旨在指向wordpress的根目录,例如www.yourdomain.com/wordpress/
Remember dirname(__FILE__)
is meant to point to the root wordpress directory, something like www.yourdomain.com/wordpress/
这篇关于致命错误:调用未定义函数add_action()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!