PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Using Merge Tags Within Page Templates

  1. Is there any way to get a $_GET variable from a form field and integrate it into a WordPress page template?

    What I am wanting to do is
    1. create a dynamic page template with
    2. assign a page to that template
    3. create a new Form that redirects to this new page on submission
    4. have the form pass values (possibly via the merge tags?) to the PHP page template (specifically to modify some of the parameters of the loop)

    Posted 11 years ago on Saturday September 29, 2012 | Permalink
  2. Blake, I'm not following what you want to do at all. Would this be before or after a form is submitted? If after, give an example of what information is submitted and how you want to use it. If you give us some specific information, we can give you some specific advice. My inclination is that what you want to do is possible, but I'm not sure yet what it is you want to do.

    Posted 11 years ago on Monday October 1, 2012 | Permalink
  3. Hey Chris,

    I would like to create a type of search form that upon submission redirects to a page assigned to a "Search Results" Page Template.

    Within the page template I would like to have a custom WP-Query that is populated by the value of a selected form field within the form.

    So here is the idea of what I'm trying to do with the merge tag:
    $query = new WP_Query( 'meta_value={selectedresponse:1:value}' );

    Any help would be awesome! Thanks

    Posted 11 years ago on Monday October 1, 2012 | Permalink
  4. Blake, take a look at these related posts for how to use date from Gravity Forms to populate a search results page. It's been asked before.

    http://www.gravityhelp.com/forums/tags/search

    Thanks

    Posted 11 years ago on Monday October 1, 2012 | Permalink
  5. This sounds exactly like what I'm trying to figure out how to do.

    "If you configure a search page that accepts query string parameters for the data that it returns then you can use a Gravity Form to build a search form that redirects to this page and passes the field values so the page can then display the results based on those values."

    How do I pass the field values?

    Posted 11 years ago on Monday October 1, 2012 | Permalink
  6. From your Gravity Form, you can pass the values in the query string, similar to how Google would do it when you search for something.

    You can do the same thing with your Gravity Form on the confirmation page. Just select "redirect" radio button on the confirmation tab of your form, enter the URL to the page where your WP_Query is going to run, check the box "Pass Field Data Via Query String" and then in the box below, enter your parameters (fixed strings) and your entry values (merge tags.)

    Then, in your page template, you read the query string being sent from your form, and your page template does the magic to craft a WP_Query and display the results. You can use this in your template to debugging the query string values being sent:

    [php]
    echo "<pre>"; print_r($wp_query->query_vars); echo "</pre>";

    Let me know if you need more help after giving that a try.

    Posted 11 years ago on Tuesday October 2, 2012 | Permalink
  7. Example form, but sending the query string to Google, not my own page template for search results: http://gravity.chrishajer.com/google-search/

    You can submit the form and see where you data goes. Nothing bad will happen. :-)

    Screenshot of my confirmation redirect settings:
    http://minus.com/lFlpbHWbVDKcX

    Posted 11 years ago on Tuesday October 2, 2012 | Permalink