Calling pods data into a sidebar widget

0

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!

asked Jul 13 '10 at 5:16

mrappleton

20

edited Jul 13 '10 at 5:18

add comment
enter at least 15 characters

2 Answers

1

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.

answered Jul 13 '10 at 7:05

Fike

208

add comment
enter at least 15 characters
1

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.

answered Jul 14 '10 at 6:42

mrappleton

20

add comment
enter at least 15 characters