How to Adjust Home URL Properly in Breadcrumb NavXT Plugin If You Are Running Multilingual Site

The modification I made in the article with titled: How To Make Breadcrumb NavXT Plugin Support for Multi Language will make that plugin will support for multilingual site. Unfortunately, the Home link in the breadcrumb (if you display it in the breadcrumb) will give you a result always pointing to the default URL’s home, and not to the home of the selected language. For example, you have a multilingual site which English as default language and Indonesian as the second language. So, the default of URL’s home in English is http://www.example.com, and unfortunately the URL’s home in Indonesian does not change, and still using: http://www.example.com instead of http://www.example.com/id/. In order to overcome this little issue but still annoying me, then this following modification will help you by replacing only two lines of code in the breadcrumb_navxt_class.php file belongs to Breadcrumb NavXT plugin.

  1. Open your breadcrumb_navxt_class.php file, and find this code:

    	//Figure out the anchor for home page
    	$breadcrumb->set_anchor($this->opt['home_anchor'], get_option('home'));

    then replace with this following code:

    	//Figure out the anchor for home page
    	$breadcrumb->set_anchor($this->opt['home_anchor'], get_bloginfo('url'));
  2. Still in the same file, find again this code:

    	//Deal with the anchor
    	$breadcrumb->set_anchor($this->opt['home_anchor'], get_option('home'));

    then replace with this following code:

    	//Deal with the anchor
    	$breadcrumb->set_anchor($this->opt['home_anchor'], get_bloginfo('url'));

Please note that this modification has been successfully applied on WordPress version 3 or above. Not tested in the older version than that.

Demo:
- http://www.ilovewordpress.org/category/general/ (English version)
- http://www.ilovewordpress.org/id/category/umum/ (Indonesian version)

Hope this helps someone out there!

Share

827 viewsPrint This Post Print This Post

Comments

  1. Jussi says:

    Thanks, saved my day!

  2. Hi very nice trick you also saved my day. One little extra question : how did you make him change the “home” into “Beranda” for the other version ?

    Thanx a lot :)

Speak Your Mind

*


*