Calling pods data into a sidebar widget
I have a problem: I'm trying to pull some pods data into a sidebar widget. I have set up a plugin which creates and registers the widget in WordPress, but when I add the following code to initiate my pods data, I get the following error message:
Fatal error: Call to a member function findRecords() on a non-object in C:\webserver\public_html\ael\wp-content\plugins\sidebar-plugin.php on line 39
Here is an excerpt of the code I'm using to get the data:
$events = new Pod('events');
$orderby = 'date ASC';
$portfolio->findRecords($orderby); //order by here
$total_rows = $portfolio->getTotalRows();
if( $total_rows>0 ) :
while ( $events->fetchRecord() ) :
//set variables
$name = $events->get_field('name');
$date = $events->get_field('date');
$location = $events->get_field('location');
?>
... data goes here ...
<?php endwhile;
endif; ?>
It seems that the Pod() method is not registering when I call it from within my plugin - can anyone offer any help on this?
Thanks in advance!
edited Jul 13 '10 at 5:18
2 Answers
As i understand, $orderby returns date ASC without apostrophes, so you should try putting them inside findRecords().
The second thing - you are calling events pod as $events, and then you try to apply findRecords on $portfolio.
Head slap
Don't you hate it when people ask stupid questions without fully checking their code? My only excuse is that I was tired.
Anyway, it works now so thank you! Also, for reference the $orderby clause works without the apostrophes in findrecords().
Thanks again for your help.


