Created
November 26, 2016 20:58
-
-
Save infoscigeek/84d5b64ed2b88dca23ddb44b2cca2017 to your computer and use it in GitHub Desktop.
Query by Custom Field
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 | |
// args | |
$args = array( | |
'numberposts' => -1, | |
'post_type' => 'event', | |
'meta_key' => 'location', | |
'meta_value' => 'Melbourne' | |
); | |
// query | |
$the_query = new WP_Query( $args ); | |
?> | |
<?php if( $the_query->have_posts() ): ?> | |
<ul> | |
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?> | |
<li> | |
<a href="<?php the_permalink(); ?>"> | |
<img src="<?php the_field('event_thumbnail'); ?>" /> | |
<?php the_title(); ?> | |
</a> | |
</li> | |
<?php endwhile; ?> | |
</ul> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment