Support » Plugins » Hacks » Is template_redirect() too late for rewrite tags?

  • I’m implementing some functionality to handle remote requests from other sites and have used add_rewrite_tag(), add_permastruct() and add_action( ‘template_redirect’, ‘myfunc’ ) to intercept the request.
    Within myfunc(), if get_query_var() returns something then my code serves up the answer. Otherwise things carry on as normal.

    BUT I notice that, between the ‘request’ filter and ‘template_redirect’ action, ‘the_posts’ gets invoked and it accesses the database unnecessarily.

    What should I be doing to prevent these database queries?

  • The topic ‘Is template_redirect() too late for rewrite tags?’ is closed to new replies.