Support » Plugin: Multisite Language Switcher » Create a hardcoded link

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Dennis Ploetner


    I’m not sure if this should be done by the Multisite Language Switcher. Seems that you need a link (somewhere in your theme) which can be localized. Something like

    <a href="#"><?php_e('Hello user','mytheme'); ?></a>

    Read on here:

    Hi realloc,

    you’re correct. I’m trying to add a link in my theme (in the index page actually), that links to the blog.
    The thing is that I have two sites, one in English and the other one in Spanish. In both sites I wanted to add a link that takes you to the blog.
    But I have two blogs, as I have two sites.

    So,the English version of the site should link to the English blog and the Spanish site should link to the Spanish blog.

    I think I need some sort of function two make the link, because a single link would always take you to the same url.

    Searching the web, I found this link that better exemplifies what I’m looking for.

    So I wanted to ask if there was a way to do this with your plugin.

    Plugin Author Dennis Ploetner


    I believe that a theme should not have such dependency on a plugin. If you – for example – plan to create a link to a specific url in all your sites of your network and you use the same theme for all of them, you can insert something like this in your theme (I reuse the example from above):

    <a href="<?php echo network_home_url( 'link_to_somewhere' ); ?>">
    <?php _e( 'read all', 'mytheme' ); ?>

    You have to modify ‘mytheme’ of course which should be the textdomain of your theme. After that you can modify the language-files of your theme and add the translation for ‘Read all’.

    There is the possibility to solve your problem “quick & dirty” with the Multisite Language Switcher too:

    $blog     = MslsBlogCollection::instance()->get_current_blog();
    $language = $blog->get_language();
    $link     = network_home_url( 'link_to_somewhere' );
    $text     = ( $language == 'es_ES' ? 'Spanish link' : 'English link');
    <a href="<?php echo $link; ?>"><?php echo $text; ?></a>


    Hi realloc, I’m not sure I’m getting your point. Or maybe I didn’t explain myself correctly (English is not my mother tongue).

    I have two sites: and Therefore, I have two blogs: and

    In your example:

    <a href="<?php echo network_home_url( 'link_to_somewhere' ); ?>">
    <?php _e( 'read all', 'mytheme' ); ?>

    I think you’re telling me how to localize the phrase “Read more”, but that would take me to the same link.

    What I want is that same link hardcoded in my theme, to either take me to or depending on which version/ language of the site I’m browsing.

    I will look into the other code you provided to see if that’s what I’m lookink for.


    Plugin Author Dennis Ploetner


    Yes, the first solution is localizing the theme. The WordPress function network_home_url() will point to the correct blog. This can be a big advantage if the endpoint is more or less fix. For example network_home_url( ‘blog’ ) should point to or resp. The second “solution” is similar but (because it uses the languages directly) a little bit dirty.

    I get it. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Create a hardcoded link’ is closed to new replies.