Provided you have a 404 page defined in your theme, Wordpress will display a 404 page if "tag" is defined in $wp_query->query_vars, and there are no posts matching that tag.
I'm writing a plugin that displays some information on each page, in addition to posts. I'd like to alter the 404 logic so that the 404 page gets displayed if there are no posts matching a tag and the plugin cannot pull up any data matching that tag. If the plugin can find data, I'd like to show a normal page, regardless of whether there are posts on that page or not ...
I've been Googling, reading code, reading the codex, and poking around here, and haven't been able to figure out where Wordpress triggers that 404, and how I can override it. (I have a feeling it might have something to do with status_header() in functions.php, but it's not clear how and when I need to hook into it).
Any help/ideas/enlightenment appreciated.