I want to create a filter for the query string is this possible?

I have spent the last few days working on and researching this question and have found no solution.

Basically I want to replace the query string which wordpress parses in order to query the database.

Read More

So for example, I want to say if the url is:

www.mysite.com/support/question

go to

www.mysite.com/another/page 

I know I can setup fancy rewrite rules using the add_rewrite_rules filter, but this is over complicating the situation. I don’t want to go down this route, all I want to do replace the exact request i.e. support/question with another/page

Is there a simple way to pass a different query string to wordpress?

Related posts

Leave a Reply

3 comments

  1. To at least answer the title of your question, the pre_get_posts filter may be useful. From the Codex:

    This hook is called after the query variable object is created, but
    before the actual query is run.

    The pre_get_posts action gives developers access to the $query object
    by reference (any changes you make to $query are made directly to the
    original object – no return value is necessary).

  2. You can use simple JavaScript to achieve this:

    <script type="text/javascript">    
        if ( window.location == "www.mysite.com/support/question" ) {   
            window.location = "www.mysite.com/another/page"     
    }
    </script>