Support » Plugin: Multisite Language Switcher » All links works except blog page

  • Thanks a lot for this plugin!

    It’s difficult to me to explain what’s wrong. I’ll try.

    I have a multisite in English as main language over / and a Spanish site over /es. I have installed the plugin, mapped all pages in both languages and all seems to be working perfect except for the blog page.

    When I’m in the blog page in each sites, the flag redirects me to the language’s home page. When I’m in, for instance: example.com/blog (English site) I would like to click in the Spanish flag to go to example.com/es/blog but I’m redirected to the English site home page /. If I’m in example.com/es/blog and click the flag I’m redirected to Spanish home page /es.

    It’s important to say that I’ve configured my permalinks with /blog/%postname%/ on both sites and I think the problem come from here. I cannot change this.

    Thanks!
    Alex

    https://wordpress.org/plugins/multisite-language-switcher/

Viewing 1 replies (of 1 total)
  • Thread Starter alfupe

    (@alfupe)

    Using the msls_options_get_permalink filter from http://msls.co/hooks-filters-and-actions/ I was able to make a little tweak to make it work again.

    /**
     * Hack para mapear a mano la url del blog
     *
     * @param string $language
     * @return string
     */
    function my_msls_options_get_permalink( $url ) {
    
    	if ( endsWith(get_the_permalink(), "blog/") ) {
    		$url .= "blog/";
    	}
    
    	return $url;
    }
    add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );
    
    function endsWith($haystack, $needle)
    {
    	$length = strlen($needle);
    	if ($length == 0) {
    		return true;
    	}
    
    	return (substr($haystack, -$length) === $needle);
    }
Viewing 1 replies (of 1 total)
  • The topic ‘All links works except blog page’ is closed to new replies.