[wp-hackers] Throw 404 error via plugin

Will Anderson will at itsananderson.com
Thu Jan 13 05:48:58 UTC 2011


404 isn't a redirect, it's a not found error. These are, for the most part,
completely different problems.

Ryan, when you call set_404() on init, it sets the $wp_query->is_404
variable to true, but when $wp_query is actually constructed (after init),
init_query_flags() is called, which will set $wp_query->is_404 to false
again. You need to hook into pre_get_posts so that your changes to $wp_query
aren't overwritten.

On Thu, Jan 13, 2011 at 12:33 AM, 24/7 <24-7 at gmx.net> wrote:

> I'm trying to achieve something similar with my init class and opened
> an thread just some minutes before you [1].
>
> Maybe you got more luck with my code and get a 404-redirect working.
>
> [1]
> http://groups.google.com/group/wp-hackers/browse_thread/thread/e7e5b54af635c429?hl=de
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list