• Hi Everyone –

    Im trying to pass a parameter via URL (e.g. /page?myvar=123) and use it on any subsequent page, e.g. three pages later.

    I followed advice here, but it doesn’t seem to be working: https://www.webopius.com/content/137/using-custom-url-parameters-in-wordpress

    I have the plugin installed containing this code:

    <?php
    /* Plugin Name: Parameter
    Plugin URI: https://webopius.com/
    Description: A plugin to allow parameters to be passed in the URL and recognized by WordPress
    Author: Adam Boyse and Pete Indelicato
    Version: 1.1
    Author URI: https://www.webopius.com/
    */
    add_filter('query_vars', 'parameter_queryvars' );
    function parameter_queryvars( $qvars )
    {
    $qvars[] = ' myvar';
    return $qvars;
    }
    ?>

    I have a button on PAGE A that navigates to : /pete-test-pmp-plan-picker?myvar=25

    And on the page I want to retrieve the variable, I have this (using an insert php plugin):

    [insert_php]
    echo hello;
    global $wp_query;
    if (isset($wp_query->query_vars['myvar']))
    {
    print $wp_query->query_vars['myvar'];
    }
    [/insert_php]

    On that page I see the “hello” but I don’t see anything about “myvar”.

    Please help?!

  • The topic ‘Passing and saving a parameter via URL’ is closed to new replies.