Convert property listing prices to another currency in WordPress
To convert property listing prices to another currency in WordPress, the price has to pass through the currency switcher. A real estate, classifieds, rental or booking theme prints its prices with its own code, so when a visitor picks another currency in the WPCS switcher, those prices stay as they are. WPCS converts what its own [wpcs_price] shortcode and PHP functions print. The fix is to make the theme print its price through them. Usually that means changing one template file or function in a child theme, and the steps are the same for property, rental, tour and classified listings.
Why theme and listing prices do not switch currency
The switcher does not scan the page for numbers. It stores the visitor's currency, and every price printed with [wpcs_price] is calculated in that currency: the amount in your base currency multiplied by the rate, formatted, and shown with the currency symbol. A theme that reads property_price from the post meta and prints $250,000 with its own formatting never asks WPCS anything, so its prices cannot change.
Two things must be right before you start:
- The amounts the theme stores must be in the WPCS base currency, the one whose radio button is selected in the Currencies tab and whose rate is 1. If listings are entered in euros, make EUR the base currency.
- The stored value must be a plain number such as
250000or1250.50. Text such as250,000,$250kor Price on request is read as a wrong number or not at all, so text prices need the separate handling shown below, and formatted numbers must be cleaned first.
Find where the theme prints the price
Open a listing and look at the price HTML in the browser's inspector: its CSS class (for example item-price or listing-price) is a good search term. Then search the theme folder for that class and for get_post_meta calls near it. You will find one of three things:
- A template file (a card, a single listing page) that reads the meta field and echoes it;
- a theme function such as
theme_listing_price()that builds the price HTML and is called from several templates; - a theme shortcode or widget that outputs the price.
The same search tells you the meta key that holds the amount, the second argument of get_post_meta(). If the theme is complex, its author can name the template, function and meta key in one answer. Make every change in a child theme, because a theme update replaces the parent theme's files.
Print the price with [wpcs_price]
Inside the loop or on a single listing page, the shortcode can read the meta field itself; meta_value is the meta key and the current post is used:
<?php echo do_shortcode('[wpcs_price meta_value="property_price"]'); ?>
Outside the loop (a sidebar, a map pop-up, a related listings block), add post_id: [wpcs_price post_id="123" meta_value="property_price"]. When the theme code already holds the amount in a variable, pass it as value, and keep text prices as text:
<?php
// Child theme copy of the template that prints the listing price.
// "property_price" is an example: use the meta key your theme uses.
$amount = get_post_meta(get_the_ID(), 'property_price', true);
if (is_numeric($amount)) {
echo do_shortcode('[wpcs_price value="' . (float) $amount . '"]');
} else {
echo esc_html($amount); // "Price on request" and other text
}
?>
Remove the theme's own currency symbol around the old output: [wpcs_price] prints the symbol of the selected currency itself, otherwise you get two symbols. Prefixes and postfixes such as From or / month stay as they are; convert each number separately when a listing has a sale price and a rent price.
Template files
Files that the theme loads with get_template_part() or locate_template() can be overridden: copy the file to the same path inside the child theme and edit the copy. WordPress loads the child theme's version first.
Theme functions
Many themes declare their template functions inside if ( ! function_exists( 'theme_listing_price' ) ). The child theme's functions.php loads before the parent theme's, so a function with the same name defined there replaces the theme's version everywhere it is used. Copy the original function, keep what it returns or echoes, and change only the amount:
/*
* Child theme functions.php. Works only when the parent theme wraps
* theme_listing_price() in if ( ! function_exists() ). The function
* and meta key names are examples: use the ones from your theme.
*/
function theme_listing_price() {
$amount = get_post_meta(get_the_ID(), 'property_price', true);
if (!is_numeric($amount)) {
return esc_html($amount);
}
return do_shortcode('[wpcs_price value="' . (float) $amount . '"]');
}
Houzez, for example, builds listing prices in houzez_listing_price(), declared this way. Check your theme version before copying any function, since its internals change between releases.
Theme shortcodes
When the price comes from a theme shortcode, register a new handler for the same tag after the theme has registered its own:
/*
* Child theme functions.php: replace the theme shortcode [listing_price]
* with a version that prints the price through WPCS.
* "listing_price" and "property_price" are examples.
*/
add_action('init', function () {
remove_shortcode('listing_price');
add_shortcode('listing_price', function ($atts) {
$atts = shortcode_atts(array('id' => get_the_ID()), $atts);
$amount = get_post_meta((int) $atts['id'], 'property_price', true);
if (!is_numeric($amount)) {
return esc_html($amount);
}
return do_shortcode('[wpcs_price value="' . (float) $amount . '"]');
});
}, 99);
If the theme offers a filter on its price output, that is the cleanest place of all: return the [wpcs_price] output from your filter callback and nothing in the theme needs copying.
Listing, booking and page builder plugins
When the listings come from a plugin (a directory, rental or booking plugin) or from a page builder widget, the price is printed by that plugin's code, and the same rule applies: its output has to go through [wpcs_price]. Look for one of these, in this order:
- a filter hook on the price HTML or the formatted amount;
- a template override system (many plugins load their templates from a folder in the active theme first);
- a card template you design yourself. In an Elementor Pro Loop Item template, for example, put a Shortcode widget with
[wpcs_price meta_value="your_price_key"]where the price goes; the shortcode reads the meta field of each listing in the loop.
If none exists, ask the plugin author for a hook or the template path. A price inside a widget that offers no hook, template or setting for it cannot be converted from the outside.
Calculated totals: convert in PHP
Totals that your code calculates, such as nights multiplied by the price per night, a deposit or a fee, should be calculated in the base currency and converted once, at output:
<?php
// Calculate in the base currency, convert only for display.
$per_night = (float) get_post_meta(get_the_ID(), 'price_per_night', true);
$total = $nights * $per_night; // $nights comes from your booking form
// Full price HTML with the currency symbol (also redrawn on cached pages):
echo do_shortcode('[wpcs_price value="' . $total . '"]');
// Or only the converted number, formatted for the selected currency:
global $WPCS;
if (isset($WPCS)) {
echo esc_html($WPCS->wpcs_exchange_value($total));
}
?>
$WPCS->wpcs_exchange_value() returns a formatted string with the separators of the selected currency, so do not calculate with its result. Print the currency code next to it with $WPCS->current_currency if you need it. On a site with a page cache, prefer the shortcode: with I am using cache plugin on my site enabled, only [wpcs_price] output is redrawn for each visitor (see currency switcher and cache plugins).
Check the result and know the limits
- Switch currencies on a listing card and a single listing page: the amount, symbol and format should change on both.
- Listing prices in a currency that the rate services do not cover need a rate typed in by hand; see exchange rate errors.
- Theme search filters and sorting by price still work with the stored base-currency amounts; they do not convert.
- WPCS changes how prices are displayed. Payments, booking checkouts, invoices and emails stay in the currency the theme or booking plugin uses. For a WooCommerce shop, the sister plugin FOX switches the currency of the cart and checkout too; see WPCS or FOX.
If the theme prints its prices in a way none of these methods reaches, open a topic on the WPCS support forum with the theme name, the template or function that prints the price and the meta key it reads.