Any updates on this?
I’m facing the issue, one year later. Doesn’t seem to be fixed @timmse. This is a massive bug that means we can’t send people to 404 using PHP, which is quite a usual thing.
Works on every other theme I tested it with.
I used a more complex code snippet in the video, but it’s the same if I try to send a normal permalink to 404. I also didn’t use a child theme, as this is for demonstration only. It’s from wetransfer, so it won’t be up for long: WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free.
You get the same error page if you set your site not to index (in the WordPress settings) and open /wp-sitemap.xml.
That’s a copy of my answer over here: