Archived topic
disable default content in archive loop question
1 reply · Started by Tesco on October 11, 2022
Viewing posts 1–2 of 2
I'm using this to disable default content in archive loop but I'm having an unwanted conflict in no results page making that there's the no content information appearing.
Is there anything to be done here to avoid this code from disabling the default content on that page (no results page)?
add_filter( 'generate_do_template_part', 'disable_default_content_in_archive_loop');
function disable_default_content_in_archive_loop ($do) {
if ( is_archive() || is_search()) {
return false;
}
return $do;
}
add_filter( 'get_search_form', 'custom_search_form', 100 );
Hi Tesco,
Try change the code to:
add_filter( 'generate_do_template_part', 'disable_default_content_in_archive_loop');
function disable_default_content_in_archive_loop ($do) {
if ( is_archive() || (is_search() && 0 != $GLOBALS['wp_query']->found_posts)) {
return false;
}
return $do;
}
This archived topic is closed to new replies.