Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Additional condition in the elements

  • 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.

  • 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.

  • 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.

  • 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.

  • 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 );
  • Thank you, it worked perfectly, I used the first condition to activate and the second to delete.

  • Nice 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.