+1 on this issue for me as well.
Here’s a snippet that I’ve used before to bring up a larger map view with directions.
<a href="https://www.google.com/maps?saddr=My+Location&daddr=<?php $location = get_field('map'); echo $location['lat'] . ',' . $location['lng']; ?>">Get Directions</a>
If you just want the straight map, I think the url format is is: https://www.google.com/maps/@latitude,longitude,16z
(16z is the zoom level, so set whatever number you want)
Thanks Elliot.
I ended up wrapping the contents of the foreach with a conditional, and it seems to have done the trick.
foreach( $rows as $row )
{
if ( get_post_status($row->post_id) == 'publish' ) :
preg_match('_([0-9]+)_', $row->meta_key, $matches);
$name_key = 'awards_' . $matches[0] . '_award-name'; // $matches[0] contains the row number
$year_key = 'awards_' . $matches[0] . '_award-year';
$award_name = get_post_meta( $row->post_id, $name_key, true );
$award_year = get_post_meta( $row->post_id, $year_key, true );
echo '<li><span class="award-name">'. $award_name .'</span>, <span class="award-yeaer">'.$award_year.'</span></li>';
endif;
}
Hi @elliot. Perfect, that did the trick. Thanks very much for your help.
Hi Elliot,
In you original reply in this thread, you allude to this being possible using the post_object field rather than the relationship field, is that correct?
I’ve got a repeater field on a page for listing awards, which contains sub fields for ‘award-name’, ‘award-year’ and ‘award-project’ (the last of which is a post_object field, limited to the ‘projects’ custom post type.
I’m looking to query that on the single projects template, to display the name and year of any awards that have that project set for award-project.
(I know it would be much easier to do it the other way around, having the award set on the project itself and then querying them on the awards page, but I need to allow for some awards not having a project associated with it.)
Cheers
Thanks guys!
Ended up using
<?php if(get_field('slides')): $i = 0; while(has_sub_field('slides')): $i++; if ($i != 1): ?>
Blah Blah Blah
<?php endif; endwhile; endif; ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.