duanpo2813 2015-06-04 18:33
浏览 41

Wordpress URL - 使用不同自定义帖子类型的会话,Cookie或GET

Projetct of Advertisement System

Custom Post Types:

  • 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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题