Title: Create a hardcoded link
Last modified: August 20, 2016

---

# Create a hardcoded link

 *  Resolved [Carmdq](https://wordpress.org/support/users/carmdq/)
 * (@carmdq)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/)
 * Hi, I wonder how could I create a hardcoded link which is both, localizable and
   also works for my multisite install.
 * I’m working on a site with two languages, and I want to have a “read all” link
   in each site that points to its respective blog.
 * [http://wordpress.org/extend/plugins/multisite-language-switcher/](http://wordpress.org/extend/plugins/multisite-language-switcher/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/#post-3529917)
 * 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: [http://wp.smashingmagazine.com/2011/12/29/internationalizing-localizing-wordpress-theme/](http://wp.smashingmagazine.com/2011/12/29/internationalizing-localizing-wordpress-theme/)
 *  Thread Starter [Carmdq](https://wordpress.org/support/users/carmdq/)
 * (@carmdq)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/#post-3529956)
 * 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](http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/hard-coded-theme-links/)
   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](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/#post-3530044)
 * 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' ); ?>
       </a>
       ```
   
 * 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:
 *     ```
       <?php
   
       $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>
       ```
   
 * Cheers,
    Dennis.
 *  Thread Starter [Carmdq](https://wordpress.org/support/users/carmdq/)
 * (@carmdq)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/#post-3530045)
 * 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: mysite.com/en and mysite.com/es. Therefore, I have two blogs:
   mysite.com/en/blog and mysite.com/es/blog.
 * In your example:
 *     ```
       <a href="<?php echo network_home_url( 'link_to_somewhere' ); ?>">
       <?php _e( 'read all', 'mytheme' ); ?>
       </a>
       ```
   
 * 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 mysite.
   com/en/blog or mysite.com/es/blog 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.
 * Thanks
 *  Plugin Author [Dennis Ploetner](https://wordpress.org/support/users/realloc/)
 * (@realloc)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/#post-3530060)
 * 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 mysite.
   com/en/blog or mysite.com/es/blog resp. The second “solution” is similar but (
   because it uses the languages directly) a little bit dirty.
 *  Thread Starter [Carmdq](https://wordpress.org/support/users/carmdq/)
 * (@carmdq)
 * [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/#post-3530065)
 * I get it. Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Create a hardcoded link’ is closed to new replies.

 * ![](https://ps.w.org/multisite-language-switcher/assets/icon-256x256.png?rev=
   2793358)
 * [Multisite Language Switcher](https://wordpress.org/plugins/multisite-language-switcher/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/multisite-language-switcher/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/multisite-language-switcher/)
 * [Active Topics](https://wordpress.org/support/plugin/multisite-language-switcher/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multisite-language-switcher/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multisite-language-switcher/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [Carmdq](https://wordpress.org/support/users/carmdq/)
 * Last activity: [13 years, 3 months ago](https://wordpress.org/support/topic/create-a-hardcoded-link/#post-3530065)
 * Status: resolved