I'm trying to force a 404 error if attachment_id exists in the query string. I've been trying to add it to my functions.php file like so:
function do_attachment_error()
{
if(isset($_GET['attachment_id']) && $_GET['attachment_id'] != '')
{
header("HTTP/1.1 404 Not Found");
header("Status: 404 Not Found");
}
}
add_action('init', 'do_attachment_error' );
The problem is that while the code recognizes that attachment_id exists in the query string, it doesn't actually set the 404 error in the header. Ideally I would be serving up the standard 404 error page... but I don't know how to do that either. I wish their was a show_error function like codeigniter, but no love.