• Resolved zarzash

    (@zarzash)


    Hi,

    On my blog, using the Forever theme with Polylang, my main page is my post page and is called “home”. It is also automatically translated to “acceuil” or “inicio” for different languages.

    I would like to change the above name to “blog” for all languages.

    I am not using a custom menu. I saw in some posts that in some themes one would need to edit one of the php files. However, I dont manage to locate where the “home” and all of its translations are coded.

    Can you please direct me to the right files to change?

    Many thanks for your help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Could you please provide a link to your site so I can see where the text is coming from?

    Thread Starter zarzash

    (@zarzash)

    Hi Kathryn,

    sure. here is the link https://khodabandeh.photos/mamen&arash.

    Moderator Kathryn Presner

    (@zoonini)

    The easiest way by far to change the word “Home” in the default menu is by adding a custom menu and modifying the menu label item wording. Could you go that route or is there some reason why you didn’t want to?

    Thread Starter zarzash

    (@zarzash)

    I started to have a look into this. However as I have a multi language web and menu with sub-menu I was not sure if this is the right way to go (maintaining 5 menus and rebuilding the sub-menu).

    As the HOME string was automatically translated and as all the rest was so easy and trivial I was sure that changing the HOME string and its translations would be a parameter.

    I understand from your reply this is not the case.

    Moderator Kathryn Presner

    (@zoonini)

    Forever uses a custom filter to generate the “Home” menu item from a core WordPress function. To override it with your own text, you’ll need to add some new functions to a child theme. My colleague David put this together for you – it goes in your child theme’s functions.php file.

    /**
     * Let's remove the filter in our parent theme that shows the default "Home" text.
     */
     function childtheme_remove_parent_filter() {
         remove_filter( 'wp_page_menu_args', 'forever_page_menu_args' );
     }
     add_filter( 'init', 'childtheme_remove_parent_filter' );
    
     /**
      * Now that the filter from our parent theme is gone, let's add a new one.
      * Get our wp_nav_menu() fallback, wp_page_menu(), to show a customized home link.
      */
    function childtheme_page_menu_args( $args ) {
        $args['show_home'] = 'New Home Text';
        return $args;
    }
    add_filter( 'wp_page_menu_args', 'childtheme_page_menu_args' );

    Using a child theme means your tweaks won’t be overwritten when updating the theme. Here are some guides in case you haven’t made one before:

    https://codex.www.ads-software.com/Child_Themes
    https://op111.net/53/
    https://vimeo.com/39023468

    I tested this in a child theme and it’s working well for me, however I don’t know how it will work with Polylang. ?? Let me know how it goes.

    Thread Starter zarzash

    (@zarzash)

    This looks very clean and simple (of course once David has done all the work). I did not know about child theme.

    I will look into this. I will also move some of my own changes from the main theme files to the child theme!

    I will make an update here with the results.

    Moderator Kathryn Presner

    (@zoonini)

    I will look into this. I will also move some of my own changes from the main theme files to the child theme!

    Sounds good. That way your changes won’t be overwritten and lost every time you update the theme to the latest version. ?? I would recommend you start with a fresh download from the download link here:

    https://www.ads-software.com/themes/forever/

    Let me know how it goes!

    Thread Starter zarzash

    (@zarzash)

    Hi Kathryn,

    the above worked very well. Many thanks to you and David.

    To make The string Blog translatable by Polylang, I followed the receipt in https://www.ads-software.com/support/topic/plugin-polylang-changing-theme-options?replies=5.

    In short I did:

    1. applied the code proposed by David
    2. declared the string 'Blog' with pll_register_string('Blog','Blog'); in the functions.php file
    3. this maked the string 'Blog' translatable in the Settings > Languages > strings translations page/tab
    4. prepared the various translations of 'Blog' in Settings > Languages > strings translations
    5. changed in the above code from David the line

      $args[‘show_home’] = ‘New Home Text’;

      by

      $args[‘show_home’] = pll__(‘Blog’);

    Moderator Kathryn Presner

    (@zoonini)

    Great, glad that worked and thanks for providing the tweak needed for Polylang in case it helps others.

    I’ll mark this thread as resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Renaming Home Page to something else’ is closed to new replies.