Is template_redirect() too late for rewrite tags? (1 post)

  1. bobbingwide
    Posted 3 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic