I need to access the query string params in a template. How can I access these variables?


3 Answers 3


You can use PHP or plugin GET_POST_Var

color {exp:get_post_var type='get' var='color'}
page {exp:get_post_var type='get' var='page'}
size {exp:get_post_var type='get' var='size'}
  • Keep in mind that this plugin does not escape or prep the values for any particular use in markup or tags. Jan 28, 2015 at 20:05
  • 1
    yes, you right - forgot that I'm usually use my version of this plugin where I add security clean + small modification like default values for variables. I will push it on github today, and redo the links in post.
    – Max Lazar
    Jan 28, 2015 at 20:19

Two other options:

You can use the excellent Mo' Variables plugin to grab GET and POST information along with a number of other variables.

If you're already using Stash on the site you can also use {exp:stash:get} with the dynamic="yes" parameter to look for POST and GET info.

  • I was looking for something that was natively supported by Expression Engine. Is there a way that doesn't require plugins?
    – Andrew
    Jan 28, 2015 at 15:49
  • The only thing that would be natively supported by EE would be to use PHP and set the template to allow PHP. There aren't any native template tags that let you grab the PHP superglobals. We use the Mo' Variables plugin on a large number of sites and it's always worked really well.
    – Stephen T
    Jan 28, 2015 at 17:08
  • Keep in mind that this add-on does not escape or prep the values for any particular use in markup or tags. It does allow for XSS filtering, but void of the entire context of where you are using it. Like the other solution, it does not prep for use in markup either, such as forms. Jan 28, 2015 at 20:06
  • Great point - thanks for jumping in with that info Derek.
    – Stephen T
    Jan 29, 2015 at 17:10
  • Hi Derek - I'm coming back around to this thread and wondering if you have any recommendations for other solutions that could be used to pass a get variable into either a form or a tag parameter without just using straight PHP in the template. If we write a plugin is it sufficient to use the input class instead of just using the xss_clean method?
    – Stephen T
    Feb 19, 2015 at 20:55

There's even a native global variable: {current_query_string}. EE > 2.7.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.