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.

Issues with a block element

  • Hi,

    I’ve created a block element using the template for blog post search results.

    The thing is, that same block is also showing up in product search results.

    I can’t figure out how to exclude this block from product search results.

    Here’s a video that explains it better: https://monosnap.ai/file/f8liezeBI9eX0hxqWVmMoJ14ucpWiN

    Any idea how to fix this?

  • Hi Pedro.

    Please use the following code:

    add_filter('generate_element_display', function($display, $element_id) {
        // Replace 123 with the actual Element ID
        if ($element_id === 123 && is_search()) {
            return false; // Don't display on search results
        }
        return $display;
    }, 10, 2);

    Replace 123 with your element ID and just have the condition to appear in the Search Results page, no need for any exclude conditions.

    Let me know how it goes.

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