Created
April 11, 2019 12:16
-
-
Save mwhiteley16/37d6c52ecc2867a8463b579bef581697 to your computer and use it in GitHub Desktop.
single-communities.php
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 | |
$neighborhoods = get_posts( | |
array( | |
'post_type' => 'neighborhoods', | |
'post_status' => 'publish', | |
'posts_per_page' => -1, | |
'meta_query' => array( | |
array( | |
'key' => 'wd_community_relationship', // name of custom field | |
'value' => '"' . get_the_ID() . '"', // matches exactly "123", not just 123. This prevents a match for "1234" | |
'compare' => 'LIKE' | |
) | |
) | |
) | |
); ?> | |
<?php if( $neighborhoods ): ?> | |
<div class="widget widget_nav_menu"> | |
<h3>Neighborhoods in <?php the_title(); ?></h3> | |
<ul> | |
<?php foreach( $neighborhoods as $neighborhood ): ?> | |
<li> | |
<a href="<?php echo get_permalink( $neighborhood->ID ); ?>"> | |
<?php echo get_the_title( $neighborhood->ID ); ?> | |
</a> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
</div> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment