views:

24

answers:

2

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
?>

Fatal error: Call to undefined function add_action() in C:\xampp\htdocs\shizin\twitter.php on line 30

+1  A: 

As the message says, you haven defined the function add_action() and yet you're trying to use it.

Create it first.


I search your previous questions, and it seems that you copied the code of a wordpress plugin. In that case don't directly invoke the page, use the wordpress plugin system.

Colin Hebert
A: 

If add_action comes up undefined, you're trying to run it outside of your theme's core files - basically, it's running without any of the processing WordPress is supposed to do before hitting your custom functions. This should be in your theme's functions.php file or within a plugin, as Colin pointed out.

The line C:\xampp\htdocs\shizin\twitter.php definitely suggests this is in the wrong place.

Gavin