When you are using the Filter Everything Pro plugin, you will get SEO optimized filtered URLs.

Example:

  • EN: domain.com/en/products/t-shirts/color-blue
  • DE: domain.com/de/produkte/t-shirts/farbe-blau

Now these are filtered URLs for the category t-shirt and their color. Our plugin can generate the category, but the filtered URL will need some manual replacements as there is no connection between custom attributes (taxonomies).

Since version 1.3.0 this is no longer required! When you have connected taxonomies (network > translations > taxonomies) and term attributes the URL will be correct.

In below code you see a custom mapping table called $blogAttrMappingTable. Use this to add your custom strings per language:

use FilterEverythingFilterContainer;
use FilterEverythingFilterFilterSet;
use FilterEverythingFilterFilterFields;
use FilterEverythingFilterPostMetaNumEntity; add_filter('wordpress_multilingual_multisite_connected_term_links', function($links, $term_id, $filtered) { global $blogs_data; $currentBlogId = get_current_blog_id(); $currentBlogLanguage = $blogs_data[$currentBlogId]['language']; $blogAttrMappingTable = array( 'en' => array( 'color', 'blue', ), 'de'=> array( 'farbe', 'blau', ), ); if(!isset($blogAttrMappingTable[$currentBlogLanguage])) { return $links; } $wpManager = Container::instance()->getWpManager(); $queriedValues = $wpManager->getQueryVar('queried_values'); if(!empty($queriedValues)) { foreach($links as $blog_id => &$link) { $blogLanguage = $blogs_data[$blog_id]['language']; if(!isset($blogAttrMappingTable[$blogLanguage])) { continue; } foreach($queriedValues as $queriedValue) { if(empty($queriedValue['values'])) { continue; } $queriedValueAttributeName = str_replace($blogAttrMappingTable[$currentBlogLanguage], $blogAttrMappingTable[$blogLanguage], $queriedValue['slug']); $link .= $queriedValueAttributeName . '-'; $first = true; foreach($queriedValue['values'] as $queriedValueValue) { if(count($queriedValue['values']) > 1 && !$first) { $link .= '-or-'; } $queriedValueAttributeValue = str_replace($blogAttrMappingTable[$currentBlogLanguage], $blogAttrMappingTable[$blogLanguage], $queriedValueValue); $link .= $queriedValueAttributeValue; $first = false; } } } } return $links; }, 20, 3);

Leave a Reply

Your email address will not be published. Required fields are marked *