How to use query string in URL to display content on the wordpress page
-
16-04-2021 - |
Question
My wordpress page URL is like this
https:www.com/thanks-page/?origin_name=Sydney&origin_iata=SYD&destination_name=Ahmedabad&destination_iata=AMD
I need to display SYD and AMD in to the page content like this..
Flights from SYD to AMD...
How can I display those two Param query sting in to the actual wordpress page.
Thanks in advance.
Solution
Simple, you can use $_GET method.
if(isset($_GET["origin_iata"]) && !empty($_GET["origin_iata"]) && isset($_GET["destination_iata"]) && !empty($_GET["destination_iata"]))
{
echo "Flights from ".$_GET["origin_iata"]." to ".$_GET["destination_iata"]."...";
}
OTHER TIPS
You just use $_GET["origin_iata"]
and $_GET["destination_iata"]
to get those two Params you need
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange