Answers.Body: <p>Use <a href="http://buildwithcraft.com/docs/templating/craft.request#getQueryStringWithoutPath" rel="nofollow">craft.request.getQueryStringWithoutPath()</a> like so:</p>
  
  <pre><code>products/category?{{craft.request.getQueryStringWithoutPath()}}
  </code></pre>
  
  <blockquote>
    <p>Returns the query string, except for the <code>p=</code> param (which was probably added by your .htaccess redirect).</p>
  </blockquote>
  
  <p>More complicated logic to avoid the <strong>?</strong> when the query string is empty (one of several ways to do this):</p>
  
  <pre><code>{# queryString will include '?' if we have one, otherwise '' #}
  {% set queryString = (craft.request.getQueryStringWithoutPath() ? '?'~craft.request.getQueryStringWithoutPath()) %}
  products/category{{queryString}}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T18:12:55.087Z
Answers.Text: But without query or param the URL's now have a "?" in it. Is it possible to conditionally hide or show the question mark depending if there is a query in the page url?
Answers.UserDisplayName: Johannes Lamers
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T19:11:23.663Z
Answers.Text: Johannes, try something like this: `{{ craft.request.getQueryStringWithoutPath() ? '?' ~ craft.request.getQueryStringWithoutPath() }}`, or better: assign the query to a var first.
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T19:14:17.340Z
Answers.Text: @carlcs just beat me to it!
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-20T17:59:48.223Z
Answers.LastActivityDate: 2015-03-20T19:13:55.633Z
Answers.LastEditDate: 2015-03-20T19:13:55.633Z
Answers.UserDisplayName: Marion Newlevant
Body: <p>I'm trying to grab the query or param from an URL and then add it to an URL.</p>
  
  <p>like products?price=15</p>
  
  <p>How can I add the ?price=15 to a URL?</p>
  
  <p>Like products/category?price=15?</p>
  
Tags: <queries><params>
Title: How to get query or param from URL and then use in Links?
ThreadText: # How to get query or param from URL and then use in Links?
  
  (Asked by: username_0 on 2015-03-20)
  
  I'm trying to grab the query or param from an URL and then add it to an URL.
  
  like products?price=15
  
  How can I add the ?price=15 to a URL?
  
  Like products/category?price=15?
  
  **Tags:** queries, params
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-03-20. Score: 6 | Accepted answer
  
  Use [craft.request.getQueryStringWithoutPath()](http://buildwithcraft.com/docs/templating/craft.request#getQueryStringWithoutPath) like so:
  
  ```
  products/category?{{craft.request.getQueryStringWithoutPath()}}
  
  ```
  
  > Returns the query string, except for the `p=` param (which was probably added by your .htaccess redirect).
  
  More complicated logic to avoid the **?** when the query string is empty (one of several ways to do this):
  
  ```
  {# queryString will include '?' if we have one, otherwise '' #}
  {% set queryString = (craft.request.getQueryStringWithoutPath() ? '?'~craft.request.getQueryStringWithoutPath()) %}
  products/category{{queryString}}
  
  ```
  
  > **Comments:**
  > **username_0**: But without query or param the URL's now have a "?" in it. Is it possible to conditionally hide or show the question mark depending if there is a query in the page url?  
  > **username_2**: username_0, try something like this: `{{ craft.request.getQueryStringWithoutPath() ? '?' ~ craft.request.getQueryStringWithoutPath() }}`, or better: assign the query to a var first.  
  > **username_1**: @username_2 just beat me to it!  
  
  ---
  
  