Solved

Displaying WP Categories based on query string

Posted on 2011-02-24
6
339 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

First things first, I say this in many of my articles, but in this one you can take it as fact. I am not in any way an expert when it comes to WordPress. I am strictly a user. I don't know the programming languages involved, and although I could pro…
Read about how to approach blogging and about ways to do it right. Stand out from the crowd and let your knowledge be consumed by a large audience. This article aims to explain how your blog should look like,  the most important things to do while b…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now