Solved

Displaying WP Categories based on query string

Posted on 2011-02-24
6
341 Views
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:

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.
0
Comment
Question by:mikegeorge2
  • 4
  • 2
6 Comments
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 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/");
        break;
    case "CA":
        header ("Location: /states/california/");
        break;
    default:
       echo "Something went wrong";
}

Open in new window

0
 

Author Comment

by:mikegeorge2
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?
0
 

Author Comment

by:mikegeorge2
ID: 34974231
And I meant to say thank you.

So. Thank you!
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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">
0
 

Author Comment

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

Author Closing Comment

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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

839 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