-
kevinbk
I saw in the documentation that you have an additional code to create a custom condition, but it seems that that condition works with a defined ID. I would like to create an option that appears in the elements edit menu Location to display or delete the same in the original plugin, without depending on putting ID. I need to create a page language condition to display different templates according to language.
-
David
Hi there,
unfortunately that is not possible. The code fro the display rules logic is super complex and this no hooks in its code to change that behaviour.
-
kevinbk
It is a suggestion to have the option to add the URL in which that element will be activated, I think it is very much needed. So I could use the language subdirectory.
-
You should be able to use the PHP code to write your condition based on language.
-
kevinbk
I can create shortcodes to display content only in one language, but then it will get complicated would I have two templates being read?
-
Not sure what you mean, you can create 2 elements, and use PHP to disable/enable them based on language.
-
kevinbk
How would I do that?
-
The doc is here:
https://docs.generatepress.com/article/generate_element_display/And to check language, the condition would be something like this:
add_filter( 'generate_element_display', function( $display, $element_id ) { $locale = get_locale(); if ( 100 === $element_id && $locale === 'en_US' ) { $display = true; } if ( 200 === $element_id && $locale === 'fr_FR' ) { $display = true; } return $display; }, 10, 2 );
-
kevinbk
Thank you, it worked perfectly, I used the first condition to activate and the second to delete.
-
Nice 🙂
- You must be logged in to reply to this topic.