-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: allow duplicate taxonomy slugs #8
Comments
I will have a look at it. It will take some time. I might work on this in June. Are you going to WordCamp Köln? |
I am having a look at this. I am not sure it is possible as I could not find a hooks that I can use. Do you know of any plugin that has this feature? WPML does not have it. |
After doing a bit more research I found some filters in Polylang that allows a taxonomy to used without needing to translate it. /*
* Add taxonomies to the list to copy or to synchronize.
*
* @param array $taxonomies List of taxonomy names.
* @param bool $sync True if it is synchronization, false if it is a copy.
*
* @return array List of taxonomy names.
*/
function polylang_slug_copy_taxonomies( $taxonomies, $sync ){
$taxonomies[] = 'wpzoo_doc_cat';
return $taxonomies;
}
add_filter( 'pll_copy_taxonomies', 'polylang_slug_copy_taxonomies', 10, 2 );
/*
* Add taxonomies that need to be filtered.
*
* @param array $taxonomies An array of registered taxonomy names.
*
* @return array An array of registered taxonomy names.
*/
function polylang_slug_filtered_taxonomies( $taxonomies ){
$add_taxonomies = array(
'wpzoo_doc_cat' => 'wpzoo_doc_cat',
);
return array_merge( $taxonomies, $add_taxonomies );
}
add_filter( 'pll_filtered_taxonomies', 'polylang_slug_filtered_taxonomies' ); Using this method the term is the same for both languages. This change applies to the whole taxonomy is meant for taxonomies that have terms which are the same in other languages. |
What's the state of this? For now I'm thinking to just not use categories and only slugs: mysite.com/video-my-post |
@AdamQuadmon Polylang Pro offers this feature so I don't really have a reason to work on this anymore. I should perhaps add something to the documentation. |
@AdamQuadmon I was struggling with this issue too. Finally, I came up with a hack, but I can't actually recommend it, unless you're really desperate ... Let's say you've created two duplicate categories in the dashboard, where one of them has the slug The only problem is that if you want to access the category archive in Spanish at To fix this, you can create a rewrite rule that internally redirects your request to the category ID. Add this snippet to your functions.php, create a new array entry for each category, and don't forget to change the IDs. function add_rewrite_rules($rules) {
$newrules = array('es/(category/)?video/?(page/)?([0-9]+)?/?$' => '/es/?cat=1234&paged=$matches[3]');
$rules = $newrules + $rules;
return $rules;
}
add_filter('rewrite_rules_array', 'add_rewrite_rules'); When you're done, you'll have to flush your existing rewrite rules by heading to Settings > Permalinks and clicking Save Changes without making any changes. Like I said, this solution is far from perfect. You're probably much better off buying Polylang Pro or switching to multisite. I'm sure this approach will mess up your XML exports and probably cause other problems that I'm not aware of right now. But so far, I haven't found any other workaround for this. |
Wow. I came here to add this feature request, but it's been hanging since 2015... |
Sorry, I don't plan to add this feature. I personally use the pro version, and it would cost more than €100 to develop the feature. I personally like the idea of supporting the original plugin developers so that the free version will be still available in the future. I plan to leave this issue open so that the missing feature is visible. |
This would be very great! 👍
Use case:
example.com/de/leistungen/branding
example.com/en/services/branding
The text was updated successfully, but these errors were encountered: