Not working with wordpress category pages
-
I have a multisite, with Woocommerce, everything is working fine, but on the category pages, the categories doesn’t direct to their linked language, they direct to the homepage..
for example these links:
https://diamant-polymer.eu/aktuelles/
https://diamant-polymer.eu/presse/
they should link to:https://diamant-polymer.eu/en/news/
https://diamant-polymer.eu/en/press-releases/Can you check if there is a fix please?
The page I need help with: [log in to see the link]
-
I cannot access your website at all. Please, provide a working link.
Hi Dennis, it is accessible, you just have to click on “accept the risk”, because we don’t have ssl on the website yet, it is just a stage website, if you try to use Mozilla Firefox, it will work. Please try again.
Hi Dennis,
I have changed the domain now, it is on this: https://diamant-polymer.de/
now, the Product categories are not linking to their translation, but they just get random linking, sometimes to news.
for example:
https://diamant-polymer.de/produkte/dichtol/
should link to: https://diamant-polymer.de/en/products/dichtol/instead it is linking to: https://diamant-polymer.de/en/produkte/dichtol/
Although in the permalink for the english website I have the Kategorie-Basis Produkte set to: products
and in the German website it is set to: produktePlease, go first into the permalinks section of the sites. This will automatically refresh them. You don’t need to click on anything for that…
I have done that probably many times, and i did it again now as you requested, there is no change.
I’ve had the same problem. This PHP snippet resolved it for me. Change language data for your case.
/** * @param string $postlink * @param string $language * @return string */ function my_msls_options_get_permalink( $url, $language ) { if ( 'sr_RS' == $language ) { $url = str_replace( '/product/', '/proizvod/', $url ); $url = str_replace( '/products/', '/proizvodi/', $url ); } if ( 'en_US' == $language ) { $url = str_replace( '/proizvod/', '/product/', $url ); $url = str_replace( '/proizvodi/', '/products/', $url ); } return $url; } add_filter( 'msls_options_get_permalink', 'my_msls_options_get_permalink', 10, 2 );Hope it helps.
Best regards,
Goran-
This reply was modified 2 years ago by
Goran.
Thanks @goran63!
You can, whenever you have to deal with translated slugs, override it by using the filter “msls_options_get_permalink”. There is also some example code in this page: https://msls.co/developer-docs/hook-reference/
-
This reply was modified 2 years ago by
Dennis Ploetner.
-
This reply was modified 2 years ago by
Dennis Ploetner.
Thanks @realloc , thanks @goran63
it worked only for the products category, for the normal wordpress categories like news and presse-releases, it didn’t work, as the language switcher doesn’t even get the link to the other category.for example these links:
https://diamant-polymer.de/aktuelles/
https://diamant-polymer.de/presse/
they should link to:
https://diamant-polymer.de/en/news/
https://diamant-polymer.de/en/press-releases/But instead, they both link to the homepage of the other language.
This is the code i used now:
function my_msls_options_get_permalink( $url, $language ) {
if ( ‘de_DE_formal’ == $language ) {
$url = str_replace( ‘/products/’, ‘/produkte/’, $url );
$url = str_replace( ‘/news/’, ‘/aktuelles/’, $url );
$url = str_replace( ‘/press-releases/’, ‘/presse/’, $url );
}
if ( ‘en_US’ == $language ) {
$url = str_replace( ‘/produkte/’, ‘/products/’, $url );
$url = str_replace( ‘/aktuelles/’, ‘/news/’, $url );
$url = str_replace( ‘/presse/’, ‘/press-releases/’, $url );
}
return $url;
}
add_filter( ‘msls_options_get_permalink’, ‘my_msls_options_get_permalink’, 10, 2 );Your code works for me also for the connection between
presseandpresse-release.BTW there should be no problem if those categories are connected. Let’s take a simple example (there is no result but it renders the idea):
https://msls.co/category/general/ links to https://msls.co/de/category/allgemein/ and vice versa
Hi Dennis,
They are connected: (see screenshot)
but in the frontend, if you hover on the language switcher, you will see that the link goes to the homepage, it acts like they are not linked: ( see screenshot)But they look also wiered because they also have no slug. A category has normally
categoryas a slug, liketagfor the tags. They seem pages that are not connected.no, the slug is removed with options from Yoast SEO plugin.
I don’t know why yet, but it seems that there is a conflict between this plugin and WooCommerce on our website, which affect the regular WordPress categories, if i disable Woocommerce on these pages, the language switcher work fine, so any idea how i can solve this without disabling Woocommerce?
Thank you for all the valuable input. I’m currently working on some fixes. You can find more information at https://github.com/lloc/Multisite-Language-Switcher/
-
This reply was modified 2 years ago by
The topic ‘Not working with wordpress category pages’ is closed to new replies.