Displaying WP Categories based on query string

Posted on 2011-02-24
Medium Priority
Last Modified: 2012-05-11
Hi. I have a form that is going to pass it's data via a query string.

So, when somebody hit submit:

It is going it's going to go SOMEWHERE, with the user "state" in the string.

In Wordpress, the post archives are divided by categories (amongst other things)

So if I have a category page that looks like this:


I would want the form to send the person to the link above, if the person chooses "Arizona" as their home state.

I know what you are thinking! But I can't do anything on the form page or in the form logic. It's just not an option.


I think I need to send them to a page something like:


On that page, I would like a 3 or 4 second time-out, maybe show an animated gif like the computer is "thinking" and then send them to:


Thank you in advance! It is very much appreciated.
Question by:mikegeorge2
  • 4
  • 2
LVL 70

Accepted Solution

Jason C. Levine earned 2000 total points
ID: 34973889
Hi mikegeorge2,

If you have the mappings of state=XX to the appropriate WordPress page, you can do this with a switch/case loop in the PHP that processes the form:

switch ($_GET['state']) {
    case "AZ":
        header ("Location: /states/arizona/");
    case "CA":
        header ("Location: /states/california/");
       echo "Something went wrong";

Open in new window


Author Comment

ID: 34974227
This php code would just go into a wordpress page that I create... Like, domain.com/redirect/ ? for example?

Or does this do it in one step based on the query string?

Author Comment

ID: 34974231
And I meant to say thank you.

So. Thank you!
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

LVL 70

Expert Comment

by:Jason C. Levine
ID: 34974260
The code needs to go into whatever page processes the submitted form.  So you could put it in redirect.php and set the form action that way:

<form action="redirect.php" method="get">

Author Comment

ID: 34974291
Okay! Let me give it a shot.

Author Closing Comment

ID: 35046269
Sorry it took so long for me to get back to this...

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question