WordPress.org

Ready to get started?Download WordPress

Forums

Prevent the usual database queries? (1 post)

  1. dat_paulchen
    Member
    Posted 5 years ago #

    Hi all:
    I've been really wondering about the following:
    Wordpress matches every request with a rewrite rule and sets the query vars associated with the rule. Later on, these vars are used to construct a db query which will return the posts/items to display in THE loop.

    Is there ANY way to tell wordpress that the present request does not need post data from the database because a plugin "got it covered"?

    I'm programming a plugin that provides a rather large form. I created custom rewrite rules, registered add'l query_vars, hooked into the init action and the rewrite filter, but wordpress pulls posts from the db because I could not find a way to prevent this.

    Example:

    • I created the custom rewrite rule ^/myplugin/form1/?$ and mapped it to index.php?myplugin=form1
    • Then, I hook into the init action in which I add the query_var myplugin (see rewrite rule)
    • In addition, I hook into the rewrite filter. That way I can determine whether the present request has the myplugin variable (if so, I do something).
    • From here, there seems to be no way to stop any further processing by wordpress. WordPress always makes its four to seven db queries which are a waste in this case.

    Anyone? Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic