Outputting Your Easy Pod

Easy Pods Banner

This document details how to output the results of a Caldera Easy Pods query.

Caldera Easy Pods queries can be outputted either with the shortcode easy_pod or the function cep_render_easy_pod(). Each of these options will be detailed in this article.

Using The Shortcode

In any post editor, you can enter the easy_pod shortocde to output an Easy Pod. If an Easy Pod is being used for creating a search from, then the Caldera Forms shortcut must be used in its place. In either case the shortcode can be easily added using the “Caldera Easy Pods” button in the post editor.

The easy_pods shortcode only requires that you provide the name or slug for an Easy Pod using the name parameter:

[easy_pods name="hats"]

You may optionally choose a different Pods Template using the “template” parameter:

[easy_pods name="hats" template="Special Hats"]

In addition you may use an inline shortcode:

[easy_pods name="hats"]{@post_title}<ul><li>Type: {@hat_type}</li><li>Color: {@color}</li>[/easy_pods]

Using The Function

Inside of a php file, such as a WordPress theme template you can use the function cep_render_easy_pod(). The most basic usage of this function would be to output the results of an Easy Pod, using the values saved in the Caldera Easy Pods editor:

echo cep_render_easy_pod( 'hats' );

Just like with the shortcode, you can modify which Pods Template is used to render your results using the “template” parameter:

echo cep_render_easy_pod( 'hats', null, 'Special Hats Template' );

You can also pass a text string, using Pods Template syntax to this argument. This is especially useful when you wish to load template code from the file system or dynamically generate your template using conditional logic in PHP:

<?php
    global $post;
    $sizes = get_post_meta( pods_v( 'ID', $post ), 'hat_size', false );

    $template[] = '<div class="post-title">{@post_title}</div>';
    if ( in_array( 'large', $sizes ) ) {
        $template[] = 'This hat comes in large!';
    }
    $template[] = '<div>{@hat_details}</div>';

    $template = '<div class="hat-template" id="hat-' . $post->ID .' ">'.implode( '</div>', $template ).'</div>';

    echo cep_render_easy_pod( 'hats', null, $template );

This parameter is also useful for loading template code from the file system:

<?php
    global $post;

    //build a file path, based on post type for a partial to attempt to load
    $partial = trailingslashit( get_stylesheet_directory_uri() ) . 'partials/' . $post->post_type . '.html';

    //check if that file exists
    if ( file_exists( $partial ) ) {

        //if it exists use it as our template
        $template = file_get_contents( $partial );
    }else{

        //if not, use the default template
        $template = null;
    }

    echo cep_render_easy_pod( 'hats', null, $template );

The function cep_render_easy_pod() also has a parameter called “params”. This allows you to override the parameters passed to Pods::find() when querying for results to output. For more information, see this document.