Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Created August 27, 2013 20:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mustardBees/6358700 to your computer and use it in GitHub Desktop.
Using WP_Query to pull out our stores, loop through and output into a list
<?php
$args = array(
'posts_per_page' => -1,
'post_type' => 'store'
);
$stores = new WP_Query( $args );
?>
<?php if ( $stores->have_posts() ) : ?>
<div id="store-locations-map" style="width: 100%; height: 300px;"></div>
<ul id="stores">
<?php while ( $stores->have_posts() ) : $stores->the_post() ?>
<?php
$phone = get_post_meta( get_the_ID(), '_cmb_phone', true );
$location = get_post_meta( get_the_ID(), '_cmb_location', true );
?>
<li data-latitude="<?php echo $location['latitude']; ?>" data-longitude="<?php echo $location['longitude']; ?>">
<h2><?php the_title(); ?></h2>
<p>Telephone: <?php echo $phone; ?></p>
</li>
<?php endwhile; ?>
</ul>
<?php endif; wp_reset_postdata(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment