Taxonomy page – replace 404 with “No results found”

I’d like to “fake” the taxonomy page to behave like a search.

Right now if you land on localhost/search-images/deadendtag/page/2/ you get a 404 not found.

Read More

I’d simply like to replace that with page that says “No results” as if a search. That way its not mistaken as a …mistake. 😀

Related posts

Leave a Reply

2 comments

  1. The only thing I can think of is to modify the 404 page to change states based on if this taxonomy. So it can return any content I designate and change the title as well through a filter.

    function filter_404_title( $title )
    {
        if ( is_404() ) {
            $title = 'No results found.';
        }
        // You can do other filtering here, or
        // just return $title
        return $title;
    }
    
    // Hook into wp_title filter hook
    add_filter( 'wp_title', 'filter_404_title' );
    
    
    if ( get_query_var( 'post_type' ) == 'image' ) {
    
        //my fake no-results-found content
    
    } else {
    
        //the usual 404
    
    }
    

    If there is a way to go directly to the taxonomy-image-tags.php to obtain a “no results” statement though that would be ideal.