Displaying WP Categories based on query string

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:

http://azwm.com/states/arizona

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.

So...

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

azwm.com/redirect.php?state=AZ

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:

http://azwm.com/states/arizona

Thank you in advance! It is very much appreciated.
mikegeorge2Asked:
Who is Participating?
 
Jason C. LevineConnect With a Mentor No oneCommented:
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/");
        break;
    case "CA":
        header ("Location: /states/california/");
        break;
    default:
       echo "Something went wrong";
}

Open in new window

0
 
mikegeorge2Author Commented:
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?
0
 
mikegeorge2Author Commented:
And I meant to say thank you.

So. Thank you!
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
Jason C. LevineNo oneCommented:
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">
0
 
mikegeorge2Author Commented:
Okay! Let me give it a shot.
0
 
mikegeorge2Author Commented:
Sorry it took so long for me to get back to this...
0
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.

All Courses

From novice to tech pro — start learning today.