[Resolved] Need to style only native search results

Home Forums Support [Resolved] Need to style only native search results

Home Forums Support Need to style only native search results

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #2329693


    I’ve successfully styled the native WP search results using a Block Element of type Content Template.

    A plugin (GeoDirectory) has set up a custom search, that is based on a usual page with a shortcode in it.

    Here comes the problem as I understand it:

    • The custom search results are included in a normal page that hold a Shortcode. That page begins with an <article> tag.
    • The block element styles all <article> elements in search result pages, even in custom searches.
    • The result is, the whole custom search page gets the styling (background, colors) of a single search result.

    I hope my analysis makes sense. Feel free to ask.

    What I need are ideas about how to exclude the content template from custom search pages.


    Customer Support

    Hi Tobias,

    Can you show us a custom search page and the default search result page?

    Let me know!


    Hi Ying,

    Please find both links in the private area of this post.

    Look at the custom search source code: All content is covered by an article.dynamic-content-template (the template element). It surrounds the search results altogether! The template element applies the content of the last search result to the whole page. There is a hidden image (display:none) above the H2 title of the page, that corresponds to the last search result.

    I want to exclude the custom search page completely, because its content is managed by the 3rd party plugin. But excluding “all singular” or “all pages” didn’t do the job.

    If there’s a chance to add a feature to elements like “exclude by body-class”, that would be a very versatile solution!

    Thanks in advance for taking the time.

    Customer Support

    Hi there,

    you can use the generate_element_display filter hook to change the display of an element:


    And according to this reply it looks like we can use:

    geodir_is_geodir_page() to check if we’re on a geodir page.

    So putting it altogether you can use this snippet:

    add_filter( 'generate_element_display', function( $display, $element_id ) {
        if ( 100 === $element_id && geodir_is_geodir_page() ) {
            $display = false;
        return $display;
    }, 10, 2 );

    You need to change the 100 to match the ID of the Block Element you want to disable.


    Hi David,

    That code works like a charm!

    Thanks 🙂

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