Solved

Displaying WP Categories based on query string

Posted on 2011-02-24
6
338 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to count occurrences of each item in an array.

747 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

13 Experts available now in Live!

Get 1:1 Help Now