How to add a custom field to an existing metabox on the edit listing page

You can easily add additional fields to existing meta boxes when editing a listing in the dashboard.

This is based on the filter epl_meta_groups_{group_id}

Available metabox groups names

  • property_heading
  • listing_agents
  • listing_type
  • display_details
  • house_features
  • land_details
  • internal
  • external
  • heating_cooling
  • address_block
  • pricing
  • sale_details
  • rental_pricing
  • rural_features
  • commercial_leasing
  • tenant_n_outgoings
  • commercial_features
  • business_categories
  • files_n_links
  • owner_details

Register your new field to the pricing meta box

<?php
/**
 * Add custom text field in pricing section
 * @uses EPL Filter epl_meta_groups_{group_id}
 */
function my_epl_add_pricing_fields($group) {
	$group['fields'][] = array(
		'name'		=>	'my_custom_field',
		'label'		=>	__('Custom Field', 'easy-property-listings' ),
		'type'		=>	'text',
	);
	return $group;
}
add_filter('epl_meta_groups_pricing', 'my_epl_add_pricing_fields');

Display your new field

<?php
function my_custom_text_field_callback() {
	global $property;
	$custom_text_field = $property->get_property_meta('my_custom_field');
	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' );