Site logo

[Support request] Remove default content in search page

Home Forums Support [Support request] Remove default content in search page

Home Forums Support Remove default content in search page

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2505549
    Raffaele Salvemini

    Hi, I need to remove the default code in the search result page.

    I will add my custom code, but I cannot find a way to completely remove the default code, it there a PHP code to do it?

    Thanks a lot!

    #2505741
    David
    Staff
    Customer Support

    Hi there,

    in the theme archive and search templates we add the generate_has_default_loop function:

    https://github.com/tomusborne/generatepress/blob/e7fbf5693bfe4325a41cae988e3eda16550d4025/search.php#L24

    Which you can use to disable the themes loop like so:

    add_filter( 'generate_has_default_loop', function(){
        if ( is_search() ) {
            return false;
        }
        return true;
    });

    Then you can use the generate_before_main_content or the generate_after_main_content hooks to add in your own code.

    Let me know if you need more info

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