Solved

Displaying WP Categories based on query string

Posted on 2011-02-24
6
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

726 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