How to Hide the Current Active Currency in WCML (WPML Multicurrency Switcher)
If you’re using WooCommerce Multilingual & Multicurrency (WCML) — part of the WPML plugin suite — you might have noticed that the currency switcher displays all available currencies, including the currently active one.
In most cases, this is fine. But sometimes you want to hide the active currency from the list — for example, to keep your switcher clean or avoid confusion for users who might think clicking their current currency does something.
Luckily, you can hide the active currency with just a few lines of PHP code.
add_action( 'template_redirect', 'wm_buffer_currency_switcher_output' );
function wm_buffer_currency_switcher_output() {
// Start output buffering
ob_start();
// Add a callback to modify the output when buffering ends
add_action( 'shutdown', 'wm_filter_buffered_output', 0 );
}
function wm_filter_buffered_output() {
// Get the buffered output
$output = ob_get_clean();
// Use regex to remove the <li> element with class="wcml-cs-active-currency"
$output = preg_replace(
'/<li\s+class=["\']wcml-cs-active-currency["\'][^>]*>.*?<\/li>/is',
'',
$output
);
// Output the modified content
echo $output;
}