A way to avoid 404 pages in WordPress

function your_status_header_function($status_header, $header) {
    if ((int) $header == 404)
        return status_header(200);
    return $status_header;
}
add_filter( 'status_header', 'your_status_header_function', 10, 2 );

Source: errors – Is there a way to avoid 404 pages in WordPress? – WordPress Development Stack Exchange