I am generating a google map using advanced custom fields, it works great except that I have a lot of French text and they used single quotes all over the place, the single quotes are breaking my google map output..
I tried wrapping my field ( the_field(‘street_address’) ) in esc_html(), addslashes() and esc_attr() with no luck..
var contentString<?php echo $post->ID; ?> = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h3 id="firstHeading" class="firstHeading"><?php the_title(); ?></h3>'+
'<div id="bodyContent">'+
'<p><b>Address:</b> <br /><?php echo the_field('street_address'); ?>, <?php echo the_field('city'); ?><br /> ' +
'<?php echo the_field('postal_code'); ?><br><br />' +
'<b><a href="<?php echo the_field('website'); ?>" target="_blank">Visit website</a></b><br />' +
'<b><span>Distance: <?php echo get_the_distance(null, 1); ?> KM </span></b><br />' +
'</p>'+
'</div>'+
'</div>';
Not really sure about the issue in general, but this is incorrect right off the bat:
echo the_field
When you use the_field, it outputs to screen so no need to echo. Maybe that’s what the problem is.
Try replacing every instance of echo the_field
and the_field
to simply: get_field()
.
Hope this helps.
@csaborio is likely correct try echo esc_html(get_field('your-field'))
The echo didn’t matter, but this helped
get_field instead of the_field