Last active
August 29, 2015 14:07
-
-
Save joeyz/9905e0c57da3f0166f82 to your computer and use it in GitHub Desktop.
Search Results Page for a CPT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Events Search Page | |
*/ | |
global $query_string; | |
$query_args = explode("&", $query_string); | |
//this is where you would normally put your $args array | |
$search_query = array(); | |
foreach($query_args as $key => $string) { | |
$query_split = explode("=", $string); | |
$search_query[$query_split[0]] = $query_split[1]; | |
} // foreach | |
$search = new WP_Query($search_query); | |
get_header(); ?> | |
<div class="row" style="margin-top:40px"> | |
<div class="large-8 columns" role="main"> | |
<?php if ( $search->have_posts() ) : ?> | |
<header class="page-header"> | |
<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'mohegan_2' ), get_search_query() ); ?></h1> | |
</header><!-- .page-header --> | |
<?php | |
// Start the Loop. | |
while ( $search->have_posts() ) : $search->the_post();?> | |
<div class="row"> | |
<div class="large-12 columns"> | |
<img src="<?php the_field('event_image'); ?>"/> | |
</div> | |
</div> | |
<div class="row" style="padding:20px 0px"> | |
<div class="large-8 columns"> | |
<h4><?php the_title();?></h4> | |
<?php | |
if(get_field('event_date')) { | |
$date = DateTime::createFromFormat('Ymd', get_field('event_date')); | |
echo '<div>'; | |
echo $date->format('M d Y'); | |
echo '</div>'; | |
} | |
?> | |
</div> | |
<div class="large-4 columns"> | |
<a class="button [secondary tiny success ]" href="<?php the_permalink();?>">More Info</a> | |
<a class="button [secondary tiny success ]" href="<?php the_field('ticketmaster_link');?>" target="_blank">Buy Tickets</a> | |
</div> | |
</div> | |
<hr> | |
<?php | |
endwhile; | |
else : | |
// If no content, include the "No posts found" template. | |
echo 'Sorry No Events Found'; | |
endif; | |
?> | |
</div><!-- large-8 --> | |
<div class="large-4 columns"> | |
<div class="sidebar-right"> | |
<?php MS_dynamic_sidebar(); ?> | |
</div> | |
</div> | |
</div><!-- /row --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment