Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@swthate
Created August 11, 2015 13:38
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 swthate/cabf1ffe9ca329e0a834 to your computer and use it in GitHub Desktop.
Save swthate/cabf1ffe9ca329e0a834 to your computer and use it in GitHub Desktop.
<?php /* Single - State */ ?>
<?php get_header(); ?>
<?php while (have_posts() ) : the_post(); ?>
<div class="row block--page">
<div class="large-12 column">
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; ?>
<hr>
<p>Counties in <?php the_title(); ?>.</p>
<?php wp_reset_query(); ?>
<?php
$args = array(
'post_type' => 'county',
'posts_per_page' => -1,
'meta_query' => array(
'key' => 'state',
'value' => $post->ID,
),
);
$query = new WP_Query($args);
// you need to refer to the new query object you created above
if($query->have_posts()) : ?>
<ul>
<?php while($query->have_posts()) : $query->the_post(); ?>
<li><?php the_title(); ?></li>
<?php endwhile; ?>
</ul>
<?php endif; ?>
</div> <!-- / large-12 column -->
</div> <!-- / row -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment