Displaying Pod Items

display Pods content on your site
You've created a Pod, added some items to it, and now you want to display those items on your site.

Where do I put Pods display code?

Pods code can go in Pod Pages or directly within WordPress template files.

Tell Pods which content you want

Pods lets you retrieve content from the database using the Pod() class.
// Use the "event" pod
$pods = new Pod('event');

// Find 25 items, sorted by the "name" column
$pods->findRecords('name ASC', 25);

Retrieve the content

There are two options for displaying content. You could manually loop through the results using the fetchRecord() method, or you could use the showTemplate() method.

Option 1 - fetchRecord

$pods = new Pod('event');
$pods->findRecords('name ASC', 25);

while ($pods->fetchRecord()) {
    echo $pods->get_field('name');
    $start_date = $pods->get_field('start_date');
}

Option 2 - showTemplate

$pods = new Pod('event');
$pods->findRecords('name ASC', 25);
echo $pods->showTemplate('my_events');
The above code will loop through each item, passing that item's data into the "my_events" template. Since we've set the limit to 25, this means that the "my_events" template will be called up to 25 times.

An example template

In the admin area, click on the "Templates" tab and add a new Pod Template called "my_events".
{@name}
{@start_date}
{@start_date, format_date}
<?php echo $this->get_field('location'); ?>
NOTE: In the first two examples, simple Magic Tags are used. In the third example, a Magic Tag is used in combination with a Display Helper. In the last example, raw PHP is used instead of a Magic Tag.
Wordpress Cloud Hosting