Forums

[resolved] Trigger 404 (3 posts)

  1. michoch
    Member
    Posted 1 year ago #

    Hi,

    is there a way to trigger the 404 error, so the is_404() will return true?

  2. Dave Redfern
    Member
    Posted 1 year ago #

    Hello,

    Can't this just be triggered by visiting a random URL on your website which doesn't exist?

    Dave.

  3. michoch
    Member
    Posted 1 year ago #

    No, I don't want to trigger it myself, I want to trigger it from the theme or plugin files. wp_redirect() to inexisting random URL is also not an option.

    EDIT:
    ok, I found it in the source code.

    eg.:
    global $wp_query;
    $wp_query->set_404();

Topic Closed

This topic has been closed to new replies.

About this Topic