Viewing 4 replies - 1 through 4 (of 4 total)
  • Use the PHP function parse_url() on the URL. Then, use parse_str() on the query part of the parsed url:

    $url = "http://www.smartseatdiningchaircovers.com/aaa/aaa/?utm_nooverride=1&payer_email=aaa@aaa.com&txn_id=111&first_name=Adam&last_name=Eve&payment_status=123&currency=USD&client_id=1234&hash=12345";
    $url_parts = parse_url($url);
    echo '<br />PARTS:';
    print_r($url_parts);
    $query_vars = array();
    parse_str($url_parts['query'],$query_vars);
    echo '<br />VARS:';
    print_r($query_vars);
    Thread Starter jkrpublic

    (@jkrpublic)

    Thanks for your response. A few follow-up questions:
    1) This looks like php. Am I going to be better off creating a new template for my page that has this code in it or should I use a plug-in like php execution? Or have I missed something altogether in how to use the code?

    2) Since the URL is dynamic and changes with each use, could I substitute the $url = http etc etc” with this code that I found on the web:

    $url = (!empty($_SERVER[‘HTTPS’])) ? “https://&#8221;.$_SERVER[‘SERVER_NAME’].$_SERVER[‘REQUEST_URI’] : “http://&#8221;.$_SERVER[‘SERVER_NAME’].$_SERVER[‘REQUEST_URI’];

    Thanks so much.

    1) It is hard to answer without knowing the whole story. I am guessing that the ‘page’ is a WP post or page that is being displayed by the template.

    If that is the case, I think you could use a shortcode in the text of the post and have it substitute in the correct text from the URL. If you are not familiar with shortcodes, here is a tutorial.

    2) You can fill the $url variable in any way that you see fit. The way you have shown looks OK, but I have not tested it to see if it actually works.

    Thread Starter jkrpublic

    (@jkrpublic)

    I’ve been working with your code and php functions and shortcodes. I’m almost there and will push it over the line later this week. Thanks so much for the help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display Query String Parameters in web page’ is closed to new replies.