Skip to content

Instantly share code, notes, and snippets.

@indietravel
Created October 22, 2014 16:19
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 indietravel/38ed27762fb844eee0a5 to your computer and use it in GitHub Desktop.
Save indietravel/38ed27762fb844eee0a5 to your computer and use it in GitHub Desktop.
<div class="content-inner">
<?php
if ( is_category() ) {
$cat = get_query_var('cat');
$ourcat = get_category ($cat);
$category_selected = $ourcat->slug;
}
$args = array (
'post_type' => 'story',
'post_status' => 'publish',
'posts_per_page' => '6',
'category_name' => $category_selected,
);
// The Query
$cat_query = new WP_Query( $args );
?>
<?php if ( $cat_query -> have_posts() ) : ?>
<?php global $archive_i; $archive_i = 1 ?>
<?php while ( $cat_query -> have_posts() ) : $cat_query -> the_post(); ?>
<?php get_template_part('content', 'archive'); ?>
<?php $archive_i; ?>
<?php endwhile; ?>
<?php endif;
wp_reset_postdata(); // ADAPTED FOR CUSTOM POST TYPES
wp_reset_query();
?>
</div>
<?php
// WP_Query arguments
$args = array (
'post_type' => 'venue',
'post_status' => 'publish',
'pagination' => false,
'posts_per_page' => '3',
);
// The Query
$venue_query = new WP_Query( $args );
// The Loop
if ( $venue_query->have_posts() ) {
while ( $venue_query->have_posts() ) {
$venue_query->the_post();
the_title();
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment