Support » Plugin: Multisite Language Switcher » The plugin is not capturing the slug on the store page correctly.

  • Resolved spmakingwp

    (@spmakingwp)


    Hi all. The plugin is not capturing the slug on the store page correctly.

    Identify the subdirectory, but not the slug. This problem only occurs on the store page and its derivatives.

    The problem arose when a prefix change was made in the database, the whole page works perfect except this.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Update:

    New link: https://ruizbazan.com/tienda

    The problem may be in ‘Rewrites Settings’, with the automatic capture of ‘Products Slug’

    There’s no problem with the database, we tried another installation and it gave the same error.

    Plugin Author Dennis Ploetner

    (@realloc)

    Just a longshot but it is very often a translated slug – a problem that can be solved like so: http://msls.co/developer-docs/hook-reference.html#msls-options-get-permalink

    Hi, thanks for your response.

    I added the following code and it works perfect for switching from English to Spanish:
    ———————–
    function my_msls_options_get_permalink( $url, $language ) {
    if ( ‘es_ES’ == $language ) {
    $url = str_replace( ‘/shop/’, ‘/tienda/’, $url );
    }
    return $url;
    }
    add_filter( ‘msls_options_get_permalink’, ‘my_msls_options_get_permalink’, 10, 2 );
    ——————————–

    But adding the following, to switch from Spanish to English, it gives me an error.

    ————————————–
    function my_msls_options_get_permalink( $url, $language ) {
    if ( ‘en_US’ == $language ) {
    $url = str_replace( ‘/tienda/’, ‘/shop/’, $url );
    }
    return $url;
    }
    add_filter( ‘msls_options_get_permalink’, ‘my_msls_options_get_permalink’, 10, 2 );
    ————————————–

    I studied and tried various ways, but I don’t know how to add both.

    Link to the English version: https://ruizbazan.com/rugs/shop/

    Link to the Spanish version: https://ruizbazan.com/tienda/

    • This reply was modified 4 months, 2 weeks ago by spmakingwp.
    Plugin Author Dennis Ploetner

    (@realloc)

    You probably get the error “function is already defined” or similar. Try this here (it gets in one function):

    
    function my_msls_options_get_permalink( $url, $language ) {
    	if ( 'es_ES' == $language ) {
    		return str_replace( '/shop/', '/tienda/', $url );
    	}
    	elseif ( 'en_US' == $language ) {
    		return str_replace( '/tienda/', '/shop/', $url );
    	}
    	
    	return $url;
    }
    add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );

    Perfect, problem solved.

    Thank you very much Dennis, excellent support.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.