Created
July 24, 2012 14:16
-
-
Save kellymears/3170151 to your computer and use it in GitHub Desktop.
Post Archive Factory
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: Archive Query | |
* Description: Retrieves Posts | |
* | |
* @package Toolbox | |
* @since Toolbox 0.1 | |
*/ | |
get_header(); ?> | |
<!-- Body --> | |
<div class="container main-container"> | |
<div class="row"> | |
<div class="span9"> | |
<header class="entry-header"> | |
<h1 class="entry-title" style="margin-bottom: 10px;"><?php the_title(); ?></h1> | |
</header> | |
<?php | |
$archive_post_type = get_post_meta($post->ID, 'archive_query_type', true); | |
$archive_meta_key = get_post_meta($post->ID, 'archive_meta_key', true); | |
$archive_meta_value = get_post_meta($post->ID, 'archive_meta_value', true); | |
$archive_showposts = get_post_meta($post->ID, 'archive_showposts', true); | |
if($archive_post_type != '') : | |
$new_query = new WP_Query(); | |
$new_query->query('post_type='.$archive_post_type.' | |
&showposts='.$archive_showposts.' | |
&paged='.$paged.' | |
&meta_key='.$archive_meta_key.' | |
&meta_value='.$archive_meta_value.''); ?> | |
<?php while ($new_query->have_posts()) : $new_query->the_post(); ?> | |
<h3><?php the_title(); ?></h3> | |
<h3><?php the_field('date'); ?></h3> | |
<p><?php the_field('excerpt'); ?></p> | |
<p><a href="<?php echo get_permalink(); ?>" class="btn btn-primary">Read more</a></p> | |
<hr> | |
<?php endwhile; ?> | |
<?php next_posts_link('« Older Entries', $new_query->max_num_pages); ?> | |
<?php previous_posts_link('Newer Entries »'); ?> | |
<?php endif; ?> | |
</div><!-- /.span8 --> | |
<?php get_sidebar(); ?> | |
</div><!-- /.row --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment