andru26
4/14/2017 - 12:22 AM

PODS template example

PODS template example

<?php
/**
 *  Template Name: Ships
 */

get_header(); ?>

	<div id="primary" class="content-area">
		<div id="content" class="site-content" role="main">

			<?php
                //set find parameters
                $params = array( 'limit' => 4 );
                //get pods object
				$pods = pods( 'spaceship', $params );
                //loop through records
                if ( $pods->total() > 0 ) {
                    while ( $pods->fetch() ) {
                        //Put field values into variables
                        $title = $pods->display('name');
                        $permalink = site_url( 'spaceship/' . $pods->field('permalink' ) );
                        $picture = $pods->field('picture');
                        $make = $pods->display('make');
                        $model = $pods->display('model');
                        $id = $pods->field('id');
            ?>
                        <article>
                            <header class="entry-header">
                                <?php if ( ! is_null($picture) ) : ?>
                                    <div class="grid">
                                        <div class="col-third">
                                            <div class="entry-thumbnail">
                                                <?php echo wp_get_attachment_image( $picture['ID'] ); ?>
                                            </div>
                                        </div>

                                        <div class="col-2third">
                                            <h1 class="entry-title">
                                                <a href="<?php echo esc_url( $permalink); ?>" rel="bookmark"><?php _e( $title , 'PP2014' ); ?></a>
                                            </h1>
                                        </div>
                                    </div>
                                <?php else : ?>
                                    <h1 class="entry-title">
                                        <a href="<?php echo $permalink; ?>" rel="bookmark"><?php echo $title; ?></a>
                                    </h1>
                                <?php endif; ?>
                            </header><!-- .entry-header -->
                            <div class="entry-content">
                                <a href="<?php echo $permalink; ?>" rel="bookmark" class="button primary">Read More</a>
                            </div><!-- .entry-content -->
                        </article><!-- #post -->
            <?php
                    } //endwhile
                } //endif

                //do the pagination
                echo $pods->pagination( array( 'type' => 'advanced' ) );
            ?>
		</div><!-- #content -->
	</div><!-- #primary -->


<?php get_sidebar(); ?>
<?php get_footer(); ?>