Display REP Search Form on Office Hero Banner of Malcolm Listings or Malcolm Central plugin.
This guide will help you customize the office hero banner on Malcolm Real Estate website using Malcolm Listings or Malcolm Central plugin by integrating a search form based on the selected form type.
1. Access Your Theme’s Functions File
- To begin, log in to your WordPress admin dashboard.
- Next, navigate to the “Appearance” menu and select “Theme Editor.”
- In the right-hand panel, you’ll see a list of theme files. Find and click on the “functions.php” file associated with your currently active theme.
2. Insert the Provided Code
- Once you’ve opened the “functions.php” file, scroll to the bottom or a convenient location for adding custom code.
- This can also be done if you have installed code snippets plugin in your WordPress site like WPCode and Code Snippets to insert the code.
- Copy and paste the following code snippet into the “functions.php” file:
// Add Office Hero Form Type Field
if( function_exists('\Launchpad\lp__add_field') && defined( 'REP__PREFIX' ) ) {
Launchpad\lp__add_field( array(
'id' => REP__PREFIX.'_office_details_c00_f001',
'key' => 'hero_form_type',
'label' => __( 'Hero Form Type', 'rep-malcolm' ),
'type' => 'select',
'choices' => array(
'sellers' => 'For Sellers',
'buyers' => 'For Buyers',
'suburb_report' => 'Suburb Report',
),
'parent' => REP__PREFIX.'_office_details',
'position' => 15,
) );
}
// Remove default office hero banner buttons
add_filter('rep__office_hero_banner_buttons', function($buttons){
return [];
});
// Render office hero form to office
add_action('rep__office_hero_banner_body', function(){ ?>
<div class="lp-hero-form"><?php
$form_type = get_post_meta( get_the_ID(), 'hero_form_type', true ) ?: 'sellers';
if($form_type == 'sellers'):
echo do_shortcode('[rep_search_form filter_popup="on" search_types="sell,sale,lease,sold"]');
elseif($form_type == 'buyers'):
echo do_shortcode('[rep_search_form filter_popup="on" search_types="sale,lease,sold,sell"]');
else:
echo do_shortcode('[rep_search_form filter_popup="on" search_types="suburb_report"]');
endif; ?>
</div><?php
});
Result


| The code will add a field, to allow selection of hero form type and render the corresponding search form based on the selected value. |
The tutorial is only applicable to Malcolm Central and Malcolm Listings plugin. The old Malcolm Real Estate Plugin (a.k.a. Malcolm HQ) has this functionality by default.
3. Understanding the Code
The code has three parts:
- Adding an Option Field for Selecting the Form Type
- Registers a new field in the office post type using
lp__add_field. - Allows users to choose between “For Sellers,” “For Buyers,” or “Suburb Report” as the hero form type.
- Registers a new field in the office post type using
- Removing Default Office Hero Buttons
- Uses the
rep__office_hero_banner_buttonsfilter to remove any pre-existing buttons from the hero banner.
- Uses the
- Rendering the Search Form Based on the Selected Form Type
- Hooks into
rep__office_hero_banner_bodyto display the correct search form inside the office hero banner. - Determines the form type from the office post’s meta field
hero_form_type. - Displays the appropriate search form using shortcodes:
- “For Sellers” -> Displays search form for sell (property appraisal), sale, lease, and sold property search.
- “For Buyers” -> Displays search form for sale, lease, sold, and sell (property appraisal) properties.
- “Suburb Report” -> Displays a search form for suburb reports.
- Hooks into
4. Save the Changes
After adding the code, click the “Update File” button to save your changes to the “functions.php” file.
5. Testing
To see the changes in action:
- Navigate to an office post in your WordPress admin.
- Select the desired “Hero Form Type” in the office details section.
- Visit the office page on your website.
- The selected search form should appear in the hero banner, replacing the default buttons.
This customization enhances user experience by allowing different search forms based on office-specific preferences.