Important: the contents of a <squarespace:query> is not cached and may increase page load time. There is a hard limit of eight queries per page.

Querying Items

To initiate a Squarespace Query, add the query tag to your collection page with one more parameters. All parameters are optional except for collection. All code inside of the opening and closing query tags will inherit the scope set by the parameters.

<squarespace:query collection="new-blog" limit="10">
  
  <ol>
    {.repeated section items}
      <li><a href="{fullUrl}">{title}</a></li>
    {.end}
  </ol>
  
</squarespace:query>

Parameters

  • collection="" The collection URL ID (slug) to query (required)
  • limit="" The number of posts you'd like returned (number)
  • tag="" Only return items that have this tag (comma delimited)
  • category="" Only return items that have this category (comma delimited)
  • featured="" Filters the return to show only Featured posts. (boolean)

Example

This example demonstrates how to create a featured item module that is flexible enough to be used on any .list file. To achieve that flexibility we'll pull in the collection URL dynamically.

blog.list
----------------------------

<squarespace:query collection="{.section collection}{urlId}{.end}" featured="true" limit="5">
  
  <div class="featured-wrapper">
    {.repeated section items}
    <div class="featured-post">
      {.main-image?}<img {@|image-meta} />{.end}
      <h2>{title}</h2>
    </div>
    {.end}
  </div>
  
</squarespace:query>