[Support request] disable default content in archive loop question

Home Forums Support [Support request] disable default content in archive loop question

Home Forums Support disable default content in archive loop question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2370105
    Tesco

    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 );
    #2370262
    Ying
    Staff
    Customer Support

    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;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.