Search by

concept-image / wp-archive-base

concept-image

Archive and filter UI for Concept Image Acorn themes: Alpine + Tailwind components (x-archive.*, x-filter.*) published into the theme by `archive:install`, fed by concept-image/wp-query filters, AJAX through concept-image/wp-ajax (a generated per-archive action backed by ArchiveResponse).

Package info

gitlab.com/concept-image-public/wp-archive-base

Issues

pkg:composer/concept-image/wp-archive-base

Statistics

Installs: 2 604

Dependents: 2

Suggesters: 0

Stars: 0

4.0.1 2026-12-03 09:59 UTC

README

WP Archive Base

Archive and filter components for Acorn themes

Alpine.js + Tailwind Blade components for Concept Image themes (<x-archive.*>, <x-filter.*>) published into the theme and owned by the project, fed by the filters of concept-image/wp-query and sent in AJAX by concept-image/wp-ajax.

  • UI only. The data comes from the wp-query filters the archive's archiveQuery() declares (wp-custom-post-types HasArchiveQuery); WordPress runs its one main query; templates read it with X::archive() through ArchiveData. No second query, no filter engine.
  • Native fields are the source of truth. Every filter renders real checkboxes, radios, inputs and <select>s, checked by the server. Alpine only enhances the display (pills, dropdowns, keyboard). Without JavaScript the archive is a plain GET form.
  • Logic in the package, markup in the theme. Support\FilterView turns a filter name into typed options, selected values, field name and URLs ($filter->urls()); the published component classes are thin and their views pure markup: restyle freely without forking logic.
  • Form AJAX by default. <x-archive.archive :action="FilterNews::class"> wraps <x-ajax::listing>; the filters go to a per-archive #[Ajax] action generated in the theme (wp acorn archive:action News), backed by ArchiveResponse, which answers the filters and results regions and the URL. mode="navigate" and :ajax="false" are opt-in.
  • Ownership. wp acorn archive:install copies the components (and the client modules they need) into the theme, wp acorn archive:clean deletes the unused ones, like wp-core-ui.

Requirements

  • PHP 8.4+ (with ext-dom), WordPress on Bedrock, Roots Acorn 6.4+
  • concept-image/wp-query ^1.2, concept-image/wp-ajax ^0.2, concept-image/wp-custom-post-types ^4.2
  • Tailwind 4 and Alpine.js in the theme (wp-starter-theme), the wp-ajax client (wp acorn ajax:install)

Installation

composer require concept-image/wp-archive-base   # in the theme directory
wp acorn archive:install                          # the default set of components and their client
wp acorn ajax:install                             # the wp-ajax client, if not there yet

Register the client in resources/scripts/main.ts, before Alpine.start() (the command prints it):

import archive from './archive';
Alpine.plugin(archive);

The archive pattern

// app/CustomPostTypes/News.php: the archive's main query declares the filters
public static function archiveQuery(Builder $query): Builder
{
    return $query->filters([
        TaxonomyFilter::make(NewsCat::class)->archive()->withCounts(),
        MetaFilter::make('level')->options(['junior' => 'Junior', 'senior' => 'Senior'])->multiple(),
        Search::make('q'),
    ]);
}
wp acorn archive:action News   # app/Actions/Archives/FilterNews.php + archives/news/{filters,results} views
// app/View/Composers/NewsArchive.php
protected static $views = ['archive-news', 'taxonomy-news-cat'];

public function with(): array
{
    return ArchiveData::for(News::class)->toArray();   // items, total, title, formUrl, resetUrl, scope, isFiltered
}
{{-- resources/views/archive-news.blade.php --}}
<x-core.section>
  <x-core.heading :level="1">{{ $title }}</x-core.heading>
  <x-archive.archive :action="App\Actions\Archives\FilterNews::class">
    <x-archives.news.filters :items="$items" :total="$total" />
    <x-archives.news.results :items="$items" />
  </x-archive.archive>
</x-core.section>
{{-- resources/views/components/archives/news/filters.blade.php (generated, then edited) --}}
@props(['items' => null, 'total' => null])
<x-archive.filters>
  <x-filter.links name="news-cat" :label="__('Catégories', 'ci-replace')" />
  <x-filter.checkboxes name="level" :label="__('Niveau', 'ci-replace')" variant="chips" />
  <x-filter.search name="q" :label="__('Rechercher', 'ci-replace')" />
  <x-filter.active />
</x-archive.filters>

The template and the action render the same region views with the same data, so the first load and every AJAX update agree. Term links stay real links (/news-cat/tech/?level[]=junior works on first load, in AJAX, with back/forward and on reload). See docs/archive-pattern.md.

Components

TagRendersMain props
<x-archive.archive>The archive's GET form: <x-ajax::listing> (form mode), <x-ajax::navigate> (mode="navigate") or plain (:ajax="false")action, mode, ajax, url, scope, target, id, live, history
<x-archive.filters>The filters region (role="search"), <noscript> submitregion, label, submit
<x-archive.results>The results region: count, grid, empty state, paginationitems, cols (1–4), empty, count, pagination, append, tag
<x-archive.count>"12 résultats" (role="status")items or total
<x-archive.pagination>wp-query's getPagination() in a data-ajax-links wrapperitems, url
<x-archive.load-more>The more region: "6 sur 40" and a link appending the next page (data-ajax-more)items, region, target, label
<x-filter.field>Label, description, error around a controllabel, description, error, id, group, hideLabel, size
<x-filter.pillbox>Multi-select dropdown, pills in the trigger, icons and descriptions, search, clear, countsname, label, searchable, clearable, counts, hide-empty, icons, descriptions
<x-filter.select>Custom select (listbox, default: prefix, icons, descriptions, search, clear), native <select> (variant="native"), or the pillbox (multiple)name, variant, multiple, prefix, placeholder, searchable, clearable, icons, descriptions, hide-empty, options
<x-filter.checkboxes>Checkbox group variant="list\|chips\|buttons\|cards", descriptions, icons, hierarchy, "Afficher plus"name, variant, limit, counts, hide-empty, icons, descriptions
<x-filter.radios>Radios variant="list\|segmented\|cards" with an "all" choice, descriptions, iconsname, variant, all, full, options, hide-empty, icons, descriptions
<x-filter.links>Term archive links, aria-current, variant="pills\|tabs\|list"name, variant, all, hide-empty
<x-filter.toggle>On/off switch (role="switch")name, value
<x-filter.search>Search field, icon, clear buttonname, placeholder, hideLabel
<x-filter.sort>Sort <select>name, key, options, placeholder
<x-filter.range>Dual-thumb slider over {key}_min / {key}_maxname, unit
<x-filter.date-range>Two date fields {key}_from / {key}_toname, min, max
<x-filter.active>Selected values as removable pills, "Tout effacer"names, clear
<x-filter.reset>"Tout effacer" link, when filteredurl, filtered, label
<x-filter.panel>Sidebar from lg, drawer below with focus traplabel, total, active

Every filter takes name (the wp-query filter: taxonomy, meta key, search key, range name), label, size (sm, base) and, for options filters, key (the request key when the filter uses customKey()). Option components take option descriptions / description-field (term description, ACF field or a value => text map) and icons / icon-field (inline SVG sanitized by an allow-list, image URL, attachment), and hide-empty (options counted 0 by withCounts() hidden). Details: docs/components.md.

Commands

  • wp acorn archive:install [components...] [--all] [--force]: publish components (the default set: archive, filters, results, pagination, links, checkboxes, search, sort, active, and their dependencies), the client modules every installed component needs, and regenerate resources/scripts/archive/index.ts.
  • wp acorn archive:clean [--dry-run] [--force]: delete the components no theme file uses and the client modules no kept component needs, regenerate index.ts.
  • wp acorn archive:list: every component, installed, used, in the default set, its client modules.
  • wp acorn archive:action {PostType} [--force]: generate the archive's AJAX action and its filters / results region views (stubs overridable in the theme's stubs/wp-archive-base/).

Documentation

Credits

License

MIT. See LICENSE.md.