RELATED TO: Real Homes Theme

Basic Information on Property Edit page of Real Homes Theme is a very important section to add/edit/remove the information about the Property. So, in this guide you will learn about:

  • Adding more options in Basic Information
  • Displaying new options on the property details page.

1) Adding More MetaBox Options

Many clients want to add more options in the 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 the 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 the 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 in the code then you can add it to functions.php file, it will add the new field into Basic Information section. In our case, 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 → realhomes → assets → classic/modern → 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 google-map.php (classic) or map.php (modern)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); ?>
<span class="map-label">Property Address</span>
<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/