• I am trying to pass URL parameters to a WordPress template page:
    https://www.mysite.com/my_wp_page_template/?city=Anytown&state=ST

    Based on some forum examples I have added the following code to the functions.php:

    add_filter(‘query_vars’, ‘parameter_queryvars’ );
    function parameter_queryvars( $qvars )
    {
    $qvars[] = ‘City’;
    $qvars[] .= ‘State’;
    return $qvars;
    }

    And, I am trying to extract the variables in a php file that is included in a WP page using:

    report_for_city.php
    <?php
    $strCity = $_GET[“City”];
    $strState = $_GET[“State”];
    $strCityState = $strCity . ‘ ‘ . $strState;
    ?>
    <p>This page contains the report for <?php $strCityState ?>.</p>

    But, the variable is not getting inserted in the output html. The html is being inserted into the WP page, so the php template is getting invoked from the WP page using the insert-php plugin:

    [insert_php]include(‘wp-content/php/report_for_city.php’);[/insert_php]

    What am I doing wrong? How can this be fixed?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Passing URL Params to Template Page’ is closed to new replies.