Created
April 25, 2017 16:22
-
-
Save tripflex/4cd9a657a77a0027801b414796100ec9 to your computer and use it in GitHub Desktop.
Listify add custom field data to map popup ( http://listify.astoundify.com/article/1044-add-custom-information-to-the-map-marker-popup )
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 | |
function smyles_custom_listify_listing_data( $data ) { | |
// Set price key to value from get_custom_field (if there is a value). | |
// This will allow you to use {{{ data.price }}} in /templates/tmpl-map-popup.php file | |
if( $price = get_custom_field( 'price', $data['id'] ) ){ | |
$data[ 'price' ] = $price; | |
} | |
// Because we only set the key in $data array if there is a value, you can then use this in the tmpl-map-popup.php file: | |
// <# if ( typeof( data.price ) != 'undefined') { #> | |
// Price: {{{data.price}}} | |
// <# } #> | |
return $data; | |
} | |
// Set priority to 11 to run our custom one, after the core Listify adds its data | |
add_filter( 'listify_listing_data', 'smyles_custom_listify_listing_data', 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there! Could this be applied to any field we add with the field editor?
For instance I have:
listing_date and listing_time?