Skip Navigation

[Resolved] Display all languages terms in parametric filters

This support ticket is created 4 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 8 replies, has 2 voices.

Last updated by Jamal 4 years, 7 months ago.

Assisted by: Jamal.

Author
Posts
#1585019

Hi,
I have an archive view for terms displaying posts with parametric search based on several taxonomies.
In French, hidden link, posts are loaded OK as are the terms in the taxonomy filters;
In English, hidden link, posts are loaded OK, but taxonomy filters disappears.
Posts have not been and will not be translated. Therefore, they're only attached to the French version of their terms.
How may I display the translations of the terms but use the original relationship ?
Thank you.

#1585697

Hello and thank you for contacting the Toolset support.

** Please make a database backup. **
Then execute all the procedures in WPML->Support->Troubelshooting(WPML->Assistance Technique->Dépannage), especially the action to synchronize taxonomies assignment. This will make sure that the existing duplicates are assigned correct translations(countries as an example).
Make sure to execute all the procedures on the clean-up(first) section.

Then go to WPML->Taxonomy Translation(Traduction de taxonomies) and synchronize taxonomy hierarchy between languages.

If this does not help, I may need to take a copy of your website for further analysis. Let me know if you would agree with that.

#1585731

I did this and a lot of things changed, but I'm afraid I didn't understand much of it...
I definitely could use some more help; and am of course willing to give full access.

#1585735

Here is the structure of what I am trying to achieve:
- I have about 15,000 posts spread between 5 CPTs sharing 8 taxonomies and about 3000 terms;
- Most contents are in French, which is the site's default language;
- The posts are mainly in French (14,000) but some are in English (1,000);
- The English contents are not translations of the French ones: they're different contents;
- The site will also be available in English, in which pages and some terms will be translated;
- Every post must be displayed in both site languages, with an indication of the language;
- In English, if terms are translated, they should appear in English, if not they should appear in original language.

#1587315

Thank you for your feedback. I am not sure if WPML will allow you to show a post on a secondary language and assigned to the translated taxonomy. I believe that if you want to translate some taxonomies you will need to duplicate the posts to other languages.

To be sure, I have created a test site and I already installed all the required plugins, I have also imported the definitions of your post types and your custom taxonomies, you can log in with the following information:
hidden link
admin / admin123

Please create some terms and posts and the view to reproduce this issue. Let me then check why or how to get what you would like to have.

#1587359

I can't duplicate 15.000 posts!
And I can't even less ask my client to duplicate each post he posts!
That is not a solution.

I've done what you asked and posted 2 "Publications" in French. Both has pays "Mali" but only one has pays "Burkina".
In settings, I've then chosen for my CPTs "Translatable but display original if there is no translation". I then did the same for all taxonomies.
Finally I went to taxonomy translation and translated both terms Burkina and Mali, without duplicating posts.
Now, if I go to hidden link, the view works OK, as the filters.
But when I go to the English version of same page hidden link then the filters don't work anymore.

#1587371

Thank you, that's enough. No need to duplicate 15000 posts.

I'll check it from here and get back to you as soon as possible.

#1587381

Please note in the meanwhile I've posted a new Publication (in English).

I noticed :
- on French archive page, only French publications display;
- on English archive page, every publications display.

I also noticed the checkboxes for terms filters work strangely, but that worries me less.

Thank you !

#1588783

Thank you for your collaboration and feedback.

It seems that the WPML option to make a custom post type "Translatable and use translation if available or fallback to default language" won't work for content created on secondary languages. It will only work for content created in the default language.

To work around this limit, and other use cases limitations(mainly compatibility), WPML offers to duplicate content to other languages. I duplicated the publications on the test server to other languages and it seems to work:
- Duplicate French content to English.
- Duplicate English content to French.

If you can create a staging site or copy the website locally, I would like to test the following for a dozen of publications before implementing it for all the 15000:
- Duplicate the current content to other languages from WPML->Translation Management. You will need to do this at steps to not exceed the server max_execution_time and wp_memory_limit.
- Add the following code to your theme's functions.php or to Toolset->Settings->Custom code, to duplicate automatically all-new content that will be created.

add_action( 'wp_insert_post', 'my_duplicate_on_publishh' );
function my_duplicate_on_publishh( $post_id ) {
	
	// My custom post types.
	$post_types_to_duplicate = array( 'publication', 'ressource', 'evenement', 'membre' );
	
    $post = get_post( $post_id ); 
    
    // don't save for autosave
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
        return $post_id;
    }
    // dont save for revisions
    if ( isset( $post->post_type ) && $post->post_type == 'revision' ) {
        return $post_id;
    }
     
    // dont save other post types
    if ( isset( $post->post_type ) && !in_array( $post->post_type, $post_types_to_duplicate ) ) {
        return $post_id;
    }
    
    // we need this to avoid recursion see add_action at the end
    remove_action( 'wp_insert_post', 'my_duplicate_on_publishh' );
    
	// make duplicates if the post is being saved
	// #1. itself is not a duplicate of another or
	// #2. does not already have translations
 
	$is_translated = apply_filters( 'wpml_element_has_translations', '', $post_id, $post->post_type );
 
	if ( !$is_translated ) {
		do_action( 'wpml_admin_make_post_duplicates', $post_id );
	}
    
    // must hook again - see remove_action further up
    add_action( 'wp_insert_post', 'my_duplicate_on_publishh' );
}

Let me know if this works for you. If it does not, try to isolate the issue by removing all query filters and filter controls from the view, then add them again one at a time until you finish the view.