Template TypesArchive Templates

Archive & Search Templates

Build custom archive layouts and a custom search results page using the UiChemy Composer widget's loop system. Requires Pro.

Archive templates control the layout of category archives, tag archives, author archives, date archives, and custom taxonomy archives, any taxonomy your site registers gets its own Archive target automatically. A Search Results template controls what visitors see after they submit a search query, for the whole site or for one post type such as Products. Both use Composer's loop system to render lists of matching posts.

Archive and Search templates require UiChemy Pro. See Free vs Pro.

Create an Archive Template

  1. Go to UiChemy → Theme Builder.
  2. Click + Add New → Archive (or Search Results for search).
  3. It opens in the WordPress editor (Gutenberg) by default, or in Elementor if it's installed and you choose it. Use Edit on the template card to reopen it later.
  4. Add the Composer widget to the canvas.
  5. Build your archive layout.
  6. Click Update to save. Archive templates need a target. Search Results templates can have a target and conditions too, see below.

The term Provider in Archive Templates

On taxonomy archive pages (category, tag, custom taxonomy), the term Twig provider resolves to the current archive term:

<header class="archive-header uc-boxed">
  <span class="text-label">Category</span>
  <h1 class="text-heading-h1">{{ term.name }}</h1>
  {% if term.description %}
    <p class="archive-description">{{ term.description }}</p>
  {% endif %}
  <p class="text-body-sm">{{ term.count }} articles</p>
</header>

On author archive pages, use the user provider:

<h1>Posts by {{ user.name }}</h1>
<img src="{{ user.avatar('80') }}" alt="{{ user.name }}">

The Post Loop

Use get_posts with paged: current_page() to render the archive's posts:

<section class="archive-grid uc-boxed">
  <div class="uc-grid-3">
    {% for post in get_posts({
      post_type: 'post',
      posts_per_page: 9,
      paged: current_page()
    }) %}
      <article class="uc-blog-card">
        <a href="{{ post.link }}">
          <img
            src="{{ post.thumbnail.src('medium') }}"
            alt="{{ post.thumbnail.alt }}"
          >
        </a>
        <div class="card-body">
          <span class="text-label">{{ post.categories.name }}</span>
          <h2 class="text-heading-h4">{{ post.title }}</h2>
          <p>{{ post.excerpt|truncate(100) }}</p>
          <a href="{{ post.link }}" class="text-label">Read More →</a>
        </div>
      </article>
    {% endfor %}
  </div>

  {{ loop_pagination()|raw }}
</section>

current_page() reads the current page number from the URL (?loop_page=N). loop_pagination() renders numbered page navigation links.

Target and Conditions for Archives

An Archive template's primary scope is its target, chosen when you create it: blog (the main posts listing), author, date, a specific taxonomy (like Category or a custom taxonomy), or "any." Author and Date archives are also targets you can build for. The Conditions scope list for an Archive template includes Taxonomy archive, Author Archive, Date Archive, and Search Page among its options. Within a taxonomy target, conditions narrow further:

ConditionWhat it covers
Taxonomy archive (any term)All archive pages of the chosen taxonomy, such as every category
Taxonomy archive → specific termOne specific term's archive, such as one category
Author Archive / Date ArchiveAuthor or date archive pages

To apply one template to all categories and another to a specific category, use two templates targeting Category: a broad one with Include → Taxonomy archive (any term), and a specific one with Include → Taxonomy archive → the "News" term (wins for the News category).

Search Results Template

The search results template uses request.get('s') to access the search query, and get_posts with the s parameter to fetch matching results:

<section class="search-results uc-boxed">
  <header class="search-header">
    <h1 class="text-heading-h2">
      {% if request.get('s') %}
        Results for "{{ request.get('s') }}"
      {% else %}
        Search
      {% endif %}
    </h1>
  </header>

  {% set results = get_posts({
    post_type: 'any',
    posts_per_page: 10,
    s: request.get('s'),
    paged: current_page()
  }) %}

  {% if results %}
    <div class="results-list">
      {% for post in results %}
        <article class="result-item">
          <h2 class="text-heading-h4">
            <a href="{{ post.link }}">{{ post.title }}</a>
          </h2>
          <p>{{ post.excerpt|truncate(150) }}</p>
          <span class="text-label">{{ post.date|date('F j, Y') }}</span>
        </article>
      {% endfor %}
    </div>
    {{ loop_pagination()|raw }}
  {% else %}
    <p class="no-results">No results found for "{{ request.get('s') }}".</p>
    <p>Try different keywords, or go back to the <a href="{{ site.url }}">home page</a>.</p>
  {% endif %}
</section>

Search Targets and Conditions

A site search is not one situation: /?s=shirt and /?s=shirt&post_type=product are different requests. Search Results templates have a target, like Archive templates, so a shop and a blog can each have their own results layout:

  • Any Search (fallback) is used for a plain site-wide search, and for any search that has no template of its own.
  • [Post type] Search, for example Products Search, is used when the search names that one post type. Only post types WordPress allows in search results are listed.
  • A search that spans several post types counts as a general search, so it uses the fallback.

Create a template from a slot on the Canvas view to pick its target. Search Results templates also have a Conditions button, like Archive templates.

Search Results templates scoped to one post type also hold the results to that post type, so a Products Search doesn't show blog posts. A bare /?s=term stays a site-wide search.

Before UiChemy 5.4.0, every Search Results template shared a single slot and the one activated most recently showed everywhere.

Tips

Frequently Asked Questions