Created
October 14, 2014 23:34
-
-
Save craiggrella/5e504a2dfd7b81e24b88 to your computer and use it in GitHub Desktop.
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
// Custom Loop Calling Staff Picks from Author Currently being viewed | |
$picks = get_posts(array( | |
'posts_per_page' => 3, | |
'post_type' => 'staffpicks', | |
'meta_query' => array( | |
array( | |
'key' => 'author', // name of custom field | |
'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234" | |
'compare' => 'LIKE' | |
) | |
) | |
)); | |
?> | |
<?php if( $picks ): ?> | |
<ul> | |
<?php foreach( $picks as $pick ): ?> | |
<?php | |
$pick_item = get_field('author', $pick->ID); | |
?> | |
<li> | |
<a href="<?php echo get_permalink( $pick->ID ); ?>"> | |
<?php echo get_the_title( $pick->ID ); ?> | |
</a> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
<?php endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment