Snippet to customize and/or translate HivePress page slugs/urls

Hello.

Some pages/templates in Hivepress can be customized through the settings/permalink menu in the wordpress backend, however, there are several paths that can’t be translated/changed, either with LocoTranslate or through the settings menu.

Below is a codesnippet that can be passed in the function.php file, either through a childtheme or the code snippet plugin. The snippet if a collection of all the pages I’ve found so far that couldn’t previously be translated easily.

<?php
// Exit if accessed directly
if (!defined('ABSPATH')) exit;

add_filter(
    'hivepress/v1/routes',
    function ($routes) {
        $routes['user_account_page']['path'] = '/account';
        $routes['user_edit_settings_page']['path'] = '/settings';
        $routes['vendor_account_page']['path'] = '/vendor';
        $routes['vendor_dashboard_page']['path'] = '/dashboard';
        $routes['vendor_register_page']['path'] = '/register-vendor';
        $routes['user_login_page']['path'] = '/log-in';
        $routes['listings_edit_page']['path'] = '/listings';
        $routes['listing_submit_page']['path'] = '/add-listing';
        $routes['listing_submit_details_page']['path'] = '/details';
        $routes['listing_submit_profile_page']['path'] = '/profile';
        $routes['listing_renew_page']['path'] = '/renew';
        $routes['listing_renew_complete_page']['path'] = '/complete';
        $routes['listings_favorite_page']['path'] = '/favorites';
        $routes['request_submit_page']['path'] = '/add-request';
        $routes['requests_edit_page']['path'] = '/request';
        $routes['request_submit_details_page']['path'] = '/details';
        $routes['offers_view_page']['path'] = '/offers';
        $routes['messages_thread_page']['path'] = '/messages';

        return $routes;
    }
);

if you want to change the path/slug for the account page, you add the following code:

$routes['user_account_page']['path'] = '/compte';

And now you have it in french: www.yoursite.com/compte/

4 Likes

Thanks for sharing!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.