Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created April 25, 2017 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tripflex/4cd9a657a77a0027801b414796100ec9 to your computer and use it in GitHub Desktop.
Save tripflex/4cd9a657a77a0027801b414796100ec9 to your computer and use it in GitHub Desktop.
<?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 );
@WayneStratton
Copy link

Hey there! Could this be applied to any field we add with the field editor?

For instance I have:
listing_date and listing_time?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment