Modifying the Location String

Available since version 14.11.4

The wp_statistics_location_column_value filter allows you to modify the location string displayed in WP Statistics reports. This hook provides access to location data such as the city, region, and full location, which you can customize to meet your needs.

Parameters

The filter passes the following parameters:

Example Usage

Add the following hooks to the functions.php file of your active theme.

Display Only the City

add_filter('wp_statistics_location_column_value', function($result, $location, $region, $city) {
    $result = $city;

    return $result;
}, 10, 4);

Display City Before the Region

add_filter('wp_statistics_location_column_value', function($result, $location, $region, $city) {
    $result = $city . ' - ' . $region;

    return $result;
}, 10, 4);
Let’s get started
Take your business to next level

Become part of our growing family of +600,000 users and get the tools you need to make smart choices for your website. Simple, powerful insights are just a click away.