Inspiry Menu Created with Sketch.

I am going to explain following two things in this article:

  1. How to add new meta field in property meta boxes
  2. How to get value of newly added meta field

So, lets start with first point.

1. How to add new meta field in property meta boxes

Edit Real Places child theme’s functions.php file and paste the following code at its bottom.

function my_custom_meta_box($meta_boxes){
$meta_boxes[0]['fields'][] = array(
'id' => "example_meta_key", // name of the metabox
'name' => 'Example Field',
'desc' => 'Example Field Value: example',
'type' => 'text',
'std' => "",
'columns' => 12, // this is for defining width of the field as bootstrap grid
'tab' => 'details', //id of the tab
return $meta_boxes;

// filter to add custom meta box
add_filter( 'property_meta_boxes', 'my_custom_meta_box' );

  • In above code property_meta_boxes is a filter hook that is provided in Inspiry Real Estate plugin to add/modify/remove meta fields for property.
  • my_custom_meta_box is our function which we hooked with given filter hook. You can rename this function to any name of your choice.
  • example_meta_key is the meta key which we will use to get new field’s value.
  • details is the tab name in which we want to add our new meta field. You can identify the tab name by doing inspect element in property edit page and then seeing the code in console as show in following screenshot


After adding the above code you will have a new field in Basic Information tab, As shown in the following screenshot


Now lets move on to next step of getting and displaying this field’s value on property detail page.

2 – How to get value of newly added meta field

We can now easily get our recently added meta box value using following code.

$example_field = get_post_meta($post->ID, 'example_meta_key', true);

echo $example_field;

  • In above code, $post->ID is current property’s database ID.
  • get_post_meta is the default WordPress function to get meta value for a given key
  • example_meta_key is the key that we defined while creating new meta field.

I hope this guide will help you add new meta boxes and use their values.

To explore existing meta boxes code you can check register_meta_boxes function in Inspiry Real Estate plugin’s file /admin/class-inspiry-property-post-type.php

In case you need any further assistance, feel free to get in touch with our support team.