Archived topic
Remove default content in search page
1 reply · Started by Raffaele Salvemini on January 23, 2023
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!
Hi there,
in the theme archive and search templates we add the generate_has_default_loop function:
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