How to Add a Custom Measurement Unit in WPResidence
WPResidence does not currently include a custom unit field in Theme Options by default.
The available measurement units are predefined in code, such as ft, m, ac, yd, and ha. If you want to add a different unit, for example kanal, this requires code changes in the core unit arrays and conversion tables.
Important
This is a custom code modification. It is not available as a built-in theme option.
The following information is provided only as a technical guide for developers. The example code is not tested and should be reviewed carefully before being used on a live website.
Files to Update
In the current structure, the custom unit must be added in the files below.
1. wpresidence-core plugin: admin-config.php
File:
plugins/wpresidence-core/redux-framework/admin-config.php
In this file, add the new unit to the following arrays:
- $measure_array
- $measure_array_lot_size
This makes the new unit selectable in Theme Options for both Property Size and Lot Size.
2. wpresidence-core plugin: convert_functions.php
File:
plugins/wpresidence-core/api/inc/convert_functions/convert_functions.php
In this file, you must:
- Add the new unit in all measurement arrays used for conversion and formatting
- Add the matching entries in the recalculation tables so the unit conversion works correctly
- Update the logic that decides whether ² is appended for square-based units
This is the main file that controls how units are displayed and converted in the latest theme versions.
3. Theme file: widget_functions.php
File:
wp-content/themes/wpresidence/libs/widget_functions.php
If you use the Measurement Unit widget, add the new unit to the widget dropdown array in this file as well.
About the Old sup2 Note
In older notes, the recommendation may have been to edit a helper function to remove <sup>2</sup>.
In the latest theme versions, this is no longer the main path.
At the moment, the display of ² is controlled mostly in convert_functions.php and in the widget output logic, while the submit form labels now rely on the formatted unit functions.
After the Code Update
After adding the custom unit in code, go to:
Theme Options > Measurement Unit
Then select the newly added unit for:
- Property Size
- Lot Size
Save the changes and clear all cache layers, including any cache plugin, server cache, or CDN cache if enabled.
Developer Note
The following code changes are custom and are not part of the default WPResidence functionality.
Any implementation should be tested carefully in a staging environment first and reviewed by a developer before deployment on a live website.