This is to change “destination” text in URL path, for example:
https://domain.com/destination/world/australia/
can be set to be:
https://domain.com/custom-destination-path-here/world/australia/
Step 1 - Copy the code below:
/* Custom Destination Text */
add_action( 'init', 'entrada_destination_url_rewrite' );
if( ! function_exists( 'entrada_destination_url_rewrite' ) ) {
function entrada_destination_url_rewrite() {
$custom_text = 'custom-destination'; // Change this value to what you want to show inplace of destination
add_rewrite_rule( "^". $custom_text ."/([^/]*)$", 'index.php?destination=$matches[1]', 'top' );
add_rewrite_rule( "^". $custom_text ."/([^/]*)/([^/]*)$", 'index.php?destination=$matches[2]', 'top' );
}
}
add_filter( 'term_link', 'entrada_change_destination_permalink', 10, 3 );
if( ! function_exists( 'entrada_change_destination_permalink' ) ) {
function entrada_change_destination_permalink( $url, $term, $taxonomy ) {
$custom_text = 'custom-destination'; // Change this value to what you want to show inplace of destination
$taxonomy_name = 'destination';
$taxonomy_slug = 'destination';
// exit the function if taxonomy slug is not in URL
if ( strpos( $url, $taxonomy_slug ) === FALSE || $taxonomy != $taxonomy_name ) return $url;
$url = str_replace( '/' . $taxonomy_slug, '/' . $custom_text, $url );
return $url;
}
}
Step 2: Go to your WP Dashboard >> Appearance >> Editor and ensure you are in “Entrada Child” theme and then click on functions.php file.
Step 3: This will open the file in editor, and you need to place the code you copied in Step 1, right above the closing php tag which is ?>
Make sure you place it exactly above the ?> or your site will break and you will need to fix it via FTP.
Step 4: Now change the custom-destination to be your preferred text, leave the single quotation as is and only change the custom-destination part. Its shown in the image below as to where you need to make changes.
Right click the image below and open in new tab/window for a larger view.
Thank you