Inspiry Menu Created with Sketch.

I have been asked several times about how can we modify the Property Meta section on Property Edit page of Real Places Theme. So, in this KnowledgeBase Article you can learn about:

  • Adding more options in Basic Information
  • Showing them on property details page.

1) Adding More MetaBox Options

Many clients want to add more options in Basic Information section so it is not that hard if you will follow this tutorial carefully. So, the first thing to do is to add the following code in functions.php file of your theme.

add_filter( 'rwmb_meta_boxes', 'inspiry_edit_property_meta_boxes', 20 );

function inspiry_edit_property_meta_boxes( $meta_boxes )
{
 foreach ( $meta_boxes as $k => $meta_box )
 {
 if ( isset( $meta_box['id'] ) && 'property-meta-box' == $meta_box['id'] )
 { 
 $meta_boxes[$k]['fields'][] = array(
 'id' => 'example_id',
 'name' => __('Example Name', 'framework'),
 'desc' => __('Example Description', 'framework'),
 'type' => 'text',
 'std' => "",
 'columns' => 6,
 'tab' => 'details',
 );
 }
 }
 return $meta_boxes;
}

There are some important things to understand here which you have to change before adding this code in functions.php file. You have to change the following variables from the code and those variables are:

  • The id which is example_id so you have to change the example_id.
  • The name which is Example Name so kindly change Example Name.
  • The type which is text, there are multiple types you can choose from text, checkbox, map etc. To learn more about meta-box types please read this article.

Once you have changed these variables from the code then you can add it to functions.php file and it will add a new field into Basic Information section. As for our code, it displayed like this:

2) Displaying the new Metabox section on Property Details page

Now that the option has been added and working on the backend we can safely display it on front-end. To display it on Property Details page you have to decide in which section you want to show it because we have broken down the code for all the sections into different files which can be found in wp-content > themes > inspiry-realplaces > partials > property > single folder.

For example, you want to display this new option as a text address to this property and it should be displayed directly above the Property Map section. So, you have to edit the file called map.php and right after the following line of code:





<div id="property-map"></div>



add this:


<?php $address_of_property = get_post_meta($post->ID,'example_id',true); ?>
<div class="row" style="margin-top: 40px;">
<div class="col-sm-12">
<h4 class="fancy-title">Property Address</h4>
  </div>
</div>
<div class="content clearfix">
  <?php echo esc_html( $address_of_property ); ?>
</div>

 

After adding the above code you will have a new section like shown in the following screenshot.

If you still need further assistance or have a question then please feel free to open a ticket on our support site (login required):
https://support.inspirythemes.com/ask-question/