Skip to content

Instantly share code, notes, and snippets.

@nicdford
Created July 30, 2015 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicdford/b90020f4a4d8958bd326 to your computer and use it in GitHub Desktop.
Save nicdford/b90020f4a4d8958bd326 to your computer and use it in GitHub Desktop.
A page using Pods filters() and other handy functions
<?php
/**
* Template Name: Things to Do
*
* @package visitnci
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 1000, 470 ), false, '' ); ?>
<div class="hero-wrapper" data-parallax="scroll" data-image-src="<?=$src['0'];?>">
<div class="row">
<div class="columns small-12">
<h3 data-start="transform:translate3d(0px, 0%, 0px)" data-top="transform:translate3d(0px, 100%, 0px)">
Go <span>Play</span> Outside
</h3>
<div class="icon yellow" data-start="transform:translate3d(0px, 0%, 0px)" data-top="transform:translate3d(0px, 300%, 0px)">
<?=file_get_contents(get_stylesheet_directory_uri() . '/img/mountains.svg');?>
</div>
<p data-start="transform:translate3d(0px, 0%, 0px)" data-top="transform:translate3d(0px, 200%, 0px)">
Mom always said “Go Play Outside.”
</p>
</div>
</div>
</div>
<div class="row">
<?php
$things_to_do = pods( 'things_to_do' );
$limit = 9;
$params = array(
'fields' => array(
'region',
'activity',
'legend_items'
),
'label' => 'Update Results'
);
echo $things_to_do->filters( $params );
$params = array(
'limit' => $limit,
'orderby' => 'vnci_member.meta_value DESC'
);
$things_to_do->find( $params );
?>
<?php
if ( isset($_GET["pg"]) ) {
$page = intval($_GET["pg"]);
} else {
$page = 1;
}
$total = $things_to_do->total();
if ( $total > 0 ) :
$start = ( $limit * $page ) - ( $limit - 1 );
if ( $total < $limit ) {
$end = ( $start + $total ) - 1;
} else {
$end = $start + ( $limit - 1 );
}
?>
<h2>
Search Results
<span>Showing <?=$start;?> - <?=$end;?> of <?=$things_to_do->total_found();?></span>
</h2>
<ul class="pods-form-filters-results small-block-grid-1 medium-block-grid-2 large-block-grid-3">
<?php while ( $things_to_do->fetch() ) : ?>
<li class="box-grid-list-item">
<?php
$primary_image = $things_to_do->field( 'primary_image' );
$attr = array(
'alt' => trim( strip_tags( $primary_image['post_title']) ),
'title' => trim( strip_tags( $primary_image['post_title'] ) )
);
$thumbnail = pods_image( $primary_image, 'thumbnail', 0, $attr, true );
echo $thumbnail;
?>
<h4><?php echo $things_to_do->display( 'title' ); ?></h4>
<p class="region"><?php echo $things_to_do->display( 'region' ); ?></p>
<?php if ( !empty($things_to_do->field('content')) ) : ?>
<p class="description"><?php echo trim_content($things_to_do->field( 'content' ), 275); ?></p>
<?php endif; ?>
<a href="<?php echo $things_to_do->display( 'permalink' ); ?>" alt="<?php echo $things_to_do->display( 'title' ); ?>" class="btn">Learn More</a>
<?php if ( $things_to_do->field('vnci_member') ): ?>
<p class="member"> <a href=""></a><span class="icon-hellscanyon"></span>Featured Member</p>
<?php endif; ?>
</li>
<?php endwhile;
echo '</ul>';
// Add some pagination
$params = array(
'type' => 'paginate',
'next_text' => '>',
'prev_text' => '<'
);
echo $things_to_do->pagination( $params );
else : ?>
<h2>Nothing Found</h2>
<p>Sorry about that, it looks like we don't have what you're looking for.</p>
<?php endif; ?>
</div>
<?php endwhile; ?>
<?php else: ?>
<?php echo "Nothing Found"; ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment