Custom Fields with the epl_listing_meta_boxes filter

With Easy Property Listings you can create complete extra sections to your listings much like using Advanced Custom Fields plugin. However this is offers greater performance when adding a lot of extra details to listings.

Using a custom plugin instead of your theme functions file is a better solution to customising Easy Property Listings.

Custom Meta Fields with Easy Property Listings

The code below will produce the above image on your listings.

To use the various fields that you create can be done using the global $property variable combined with the get_property_meta( $your_key ) function.

While using plugins to add additional meta fields is nice and in a GUI it is much slower than hard coding as per the example above as this requires minimal SQL database requests. This allows you to add many additional fields with little impact to your website speed.

How to use a text field

function my_custom_text_field_callback() {
	global $property;
	$custom_text_field = $property->get_property_meta('property_custom_data_text');
	if ( isset($custom_text_field) ) {
		echo $custom_text_field;
	}
}
// Add after the_content of the listing
add_action( 'epl_property_content_after' , 'my_custom_text_field_callback' );

How to use a radio field

The radio field requires options to be set depending on what you want to achieve.

function my_custom_radio_field_callback() {
	global $property;
	$custom_number_field = $property->get_property_meta('property_custom_data_number');
	if ( isset($custom_number_field ) ) {
		echo $custom_number_field;
	}
}
// Add after the_content of the listing
add_action( 'epl_property_content_after' , 'my_custom_radio_field_callback' );<br>

How to use a number field

The number formatting is already taken care of when entering data and you can use the 'number' or 'decimal' to control what the user can enter on a listing.

function my_custom_number_field_callback() {
	global $property;
	$custom_number_field = $property->get_property_meta('property_custom_data_number');
	if ( isset($custom_number_field ) ) {
		echo $custom_number_field;
	}
}
// Add after the_content of the listing
add_action( 'epl_property_content_after' , 'my_custom_number_field_callback' );

How to use options or select fields

This is where you should define your options outside of the meta so you can use them in the output function.

In the big example above you can see this section:

array(
	'name'		=>	'property_custom_data_select',
	'label'		=>	__('Custom Select', 'epl'),
	'type'		=>	'select',
	'opts'		=>	array(
		'select_1'	=>	'Select 1',
		'select_2'	=>	'Select 2',
		'select_3'	=>	'Select 3',
	),
),

But lets say you want to display the 'Select 1' (value) and not the option 'select_1' (key). This is where you can store your options in a custom function and display the value.

function my_custom_select_options() {

	$options = array(
		'key_select_1'	=>	'Value Select 1',
		'key_select_2'	=>	'Value Select 2',
		'key_select_3'	=>	'Value Select 3',
	);
	return $options;
}
Now you would adjust
'opts'	=>	array(
		'select_1'	=>	'Select 1',
		'select_2'	=>	'Select 2',
		'select_3'	=>	'Select 3',
	), 
// to be 
'opts' => my_custom_select_options(),
function my_custom_select_field_callback() {
	global $property;

	$array = my_custom_select_options(); // Save your options in a variable.
	$key = $property->get_property_meta('property_custom_data_select');

	$value = array_key_exists( $key , $array ) && !empty( $array[$key] )  ? $array[$key] : '';

	echo $value;
}
// Add after the_content of the listing
add_action( 'epl_property_content_after' , 'my_custom_select_field_callback' );