wordpress php get queries from URL

121 Views Asked by At

I am making a plugin for wordpress that is located at companyname.com/event/countdown/. On this page I would like to dynamically some information from the url string to show a countdown the company can email. So in the url companyname.com/event/countdown/?city?daysleft how can I echo out the city and the days left separately? So on the page it would be:

Event at <?php echo city ?> is <?php echo daysleft ?> days away

I have seen parse_url and $_SERVER['QUERY_STRING'] but I guess I am not fully sure how to get separate parts or build the url.

1

There are 1 best solutions below

1
On BEST ANSWER

Wordpress doesn't stop the usage of typical super globals.

In this case, you can just use $_GET['city'] and $_GET['daysleft']. The query string should be well formed, unlike yours, observe:

/?city=mycity&daysleft=someinteger