Skip to content

Instantly share code, notes, and snippets.

@markduwe
Created June 14, 2017 11:53
Show Gist options
  • Save markduwe/a37406e20fddba380f810db791b56045 to your computer and use it in GitHub Desktop.
Save markduwe/a37406e20fddba380f810db791b56045 to your computer and use it in GitHub Desktop.
<?php
global $wp_query;
$modifications = array();
if( !empty( $_GET['catname'] ) && $_GET['thumbail'] == 'only_thumbnailed' ) {
$modifications['meta_query'][] = array(
'key' => '_thumbnail_id',
'value' => '',
'compare' => '!='
);
}
$args = array_merge(
$wp_query->query_vars,
$modifications
);
query_posts( $args );
get_header('blog');
?>
<div class="row">
<div class="small-12 medium-9 columns">
<form role="search" method="get" class="searchform group" action="<?php echo home_url( '/' ); ?>">
<div class="input-group">
<input class="input-group-field" type="text" placeholder="Search..." value="<?php echo get_search_query(); ?>" name="s">
<div class="input-group-button">
<input type="submit" class="button" value="Search">
</div>
</div>
</form>
<?php if (have_posts()) : ?>
<h2><?php echo $wp_query->found_posts; ?> results for "<?php the_search_query(); ?>"</h2>
<?php
p2p_type( 'author_article' )->each_connected( $wp_query );
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div <?php post_class('row align-top post page'); ?>>
<div class="small-12 medium-3 columns">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('square'); ?></a>
</div>
<div class="small-12 medium-9 columns">
<?php
$post_type = get_post_type( $post->ID );
switch( $post_type ) {
case 'post':
?>
<h6>Article</h6>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<strong>
<?php
foreach ( $post->connected as $post ) : setup_postdata( $post );
the_title();?>, <?php
endforeach;
wp_reset_postdata();
?><?php the_time('Y'); ?>
</strong>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>" class="button">Read more...</a></p>
Posted in: <?php the_category(', ') ?>
<?php
break;
case 'bibliography':
?>
<h6>Annotated Bibliography</h6>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><strong><?php global $post; $name = get_post_meta( $post->ID, '_bibliography_author', true ); echo $name; ?></strong> <?php $year = get_post_meta( $post->ID, '_bibliography_year', true ); echo $year; ?> <em><?php the_title(); ?></em> <?php $edition = get_post_meta( $post->ID, '_bibliography_edition', true ); echo $edition; ?></p>
<p><strong>Annotation(s):</strong> <?php $annotation = get_post_meta( $post->ID, '_bibliography_annotation', true ); echo wpautop($annotation); ?></p>
<p><a href="<?php the_permalink(); ?>" class="button">Read more...</a></p>
<?php
break;
case 'author':
?>
<h6>Author</h6>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>" class="button">Read more...</a></p>
<?php
break;
case 'page':
?>
<h6>Page</h6>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<p><a href="<?php the_permalink(); ?>" class="button">Read more...</a></p>
<?php
break;
}
?>
</div>
</div>
<?php endwhile; ?>
<div class="row align-middle post">
<div class="small-12 columns text-center">
<ul class="pagination text-center" role="navigation" aria-label="Pagination"><?php foundation_pagination(); ?></ul>
</div>
</div>
<?php else : ?>
<h2><?php echo $wp_query->found_posts; ?> results for "<?php the_search_query(); ?>"</h2>
<?php endif; ?>
</div>
<?php get_sidebar('article'); ?>
</div>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment