WordPress URL – Sessions, Cookies or GET using different Custom Post Types

Projetct of Advertisement System

Custom Post Types:

Read More
  • States/Cities – localhost/category/state/city
  • Coupons – localhost/site/coupons/post-name
  • Ads – localhost/site/ads/post-name
  • Enterprises – localhost/site/enterprises/post-name

Users use a select to choose state and city (it’s required).

So, they are redirected to a page url like: http://localhost/sp/jundiai/

This page is a subcategory. City(JundiaĆ­) is children of State (SP).

Coupons, Ads and Enterprises can be from any city.
But, when I access an enterprise for example, I got this URL: http://localhost/site/enterprises/post-name. Ok but. The Loop of this page, should know that the user is at the city he choose before in the select.

I thought to use JS/HTML5 LocalStorage to set two values, then return them into PHP. But seems not possible.

localStorage.setItem('state','value');
localStorage.setItem('city','value');

So in the loop of Coupons / Ads / Enterprise, I could use these values to make de wp-query.


What I need is:

A way using sessions, cookies, localstorage or anything to “record” the state/city values and pass them to the queries.
And if user changes city, theses values also changes.

Any ideas?
Thanks!

Related posts