Hi, I'm working on a real estate website, and need to plot pins on a map with a thumbnail and price of the property. I've added this snippet of php to my functions.php file, to add a thousands separator to the numeric "price" field:
add_shortcode('number-format', 'number_format_shortcode');
function number_format_shortcode($atts, $content = "") {
return number_format(floatval(wpv_do_shortcode($content)));
}
This works just fine in a regular loop, but if I use it within a map marker pop-up, it returns a zero value. This is the code I'm using within the pop-up:
[wpv-map-marker map_id='locator-map' marker_id='home-marker' marker_title='[wpv-post-title]' marker_field='wpcf-address']
<div class="markerblock">
<h4>[wpv-post-title]</h4>
<div class="marker-thumb">[wpv-post-featured-image]</div>
<div class="marker-info">
<p>[types field='plan-name'][/types]</p>
<h5>$[ts_format_number][types field='price' output='raw'][/types][/ts_format_number]</h5>
<div class="community-logo">[wpv-post-featured-image size="custom" width="150" height="150" item="@builder-home.parent"]</div>
<a class="button" href="[wpv-post-url]">More Info</a>
</div>
</div>
[/wpv-map-marker]
Is this a glitch or am I missing something? Is there an alternative method or workaround to add a thousands separator to a number?
Hi Dan,
Thank you for contacting us and I'd be happy to assist.
I've tested the code for this custom shortcode that you've shared, on my test website, but couldn't reproduce this issue. It worked as expected, even within map marker shortcode ( [wpv-map-marker] ... [/wpv-map-marker] ).
Can you please share temporary admin login details, along with the link to page, where this view can be seen?
Please also let me know, where and how the code for this custom shortcode has been included.
Note: Your next reply will be private and though no changes will be made on your website, please make a complete backup copy, before sharing the access details.
regards,
Waqar
Hi Dan,
Thank you for sharing the access details.
I noticed that the shortcode for the map marker was not included in the view's content template ( "Loop item" section ) and was placed in the "Loop Editor" section, directly.
The way that shortcode is written and included in the website (through Toolset's custom code area), it would be best to load it from inside the content template. I've done the same and the custom shortcode is working as expected, now.
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
That did the trick. Thank you!