User Guide: Change Location Taxonomy Labels in Your Houzez Child Theme
This guide explains how to modify the labels for "Area," "City," "State," and "Country" taxonomies in your Houzez child theme. These labels appear in the WordPress admin panel when adding and managing location information for your listings.
Before you begin:
- Make sure you have install houzez child theme created for your Houzez theme. Modifying the parent theme directly is not recommended as changes will be overwritten during theme updates.
- Basic understanding of WordPress theme files and functions.php is helpful.
Steps:
-
Access your child theme:
- Use a FTP client or your hosting provider's file manager to access your WordPress website files.
- Locate the folder for your child theme.
-
Locate functions.php:
- Inside your child theme folder, find the file named
functions.php
. This file contains custom code specific to your child theme.
- Inside your child theme folder, find the file named
-
Add the code snippet:
- Open
functions.php
in a text editor. - Paste the provided code snippet at the bottom of the file.
- Open
Provided Code Snippets
if( ! function_exists('custom_houzez_country_labels') ) {
function custom_houzez_country_labels($labels) {
$labels['name'] = __('Custom Country', 'houzez');
$labels['add_new_item'] = __('Add Custom Country', 'houzez');
$labels['new_item_name'] = __('New Custom Country', 'houzez');
return $labels;
}
add_filter('houzez_country_labels', 'custom_houzez_country_labels');
}
if( ! function_exists('custom_houzez_state_labels') ) {
function custom_houzez_state_labels($labels) {
$labels['name'] = __('Custom State', 'houzez');
$labels['add_new_item'] = __('Add Custom State', 'houzez');
$labels['new_item_name'] = __('New Custom State', 'houzez');
return $labels;
}
add_filter('houzez_country_labels', 'custom_houzez_state_labels'); // This line should be 'houzez_state_labels'
}
if( ! function_exists('custom_houzez_city_labels') ) {
function custom_houzez_city_labels($labels) {
$labels['name'] = __('Custom City', 'houzez');
$labels['add_new_item'] = __('Add Custom City', 'houzez');
$labels['new_item_name'] = __('New Custom City', 'houzez');
return $labels;
}
add_filter('houzez_city_labels', 'custom_houzez_city_labels');
}
if( ! function_exists('custom_houzez_area_labels') ) {
function custom_houzez_area_labels($labels) {
$labels['name'] = __('Custom Area', 'houzez');
$labels['add_new_item'] = __('Add Custom Area', 'houzez');
$labels['new_item_name'] = __('New Custom Area', 'houzez');
return $labels;
}
add_filter('houzez_area_labels', 'custom_houzez_area_labels');
}
Explanation of the code:
- Each function (
custom_houzez_country_labels
, etc.) targets a specific taxonomy ("Country," "State," etc.). - Inside each function, the code modifies three label properties:
$labels['name']
: This changes the overall label for the taxonomy (e.g., "Country" becomes "Custom Country").$labels['add_new_item']
: This changes the label for the "Add New" button.$labels['new_item_name']
: This changes the placeholder text for the new item name field.
- The
__('Text', 'domain')
function ensures the labels can be translated. Note: You'll need to create the translations if you want them in different languages.
-
Customize the labels (Optional):
- Edit the text within the single quotes (
'Custom Country'
) to match your desired labels. - Make sure to keep the quotation marks around the text.
- Edit the text within the single quotes (
-
Save the changes:
- Save the
functions.php
- Save the
Comments
0 comments
Please sign in to leave a comment.