Modern WordPress starter theme — Tailwind CSS v4 · Vite 6 · Alpine.js · Hotwire Turbo · WooCommerce
Forget page builders. wp-starter-tw4 is a lean, opinionated starting point for building WordPress themes with a truly modern frontend stack — fast, modular, and production-ready from the first commit.
- Tailwind CSS v4 with design tokens in
@theme {}— notailwind.config.js, zero extra config - Vite 6 with HMR — CSS and JS changes visible instantly, no page reload required
- Alpine.js 3 — reactive UI (menu, cart drawer, modals, dropdowns) with no jQuery
- Hotwire Turbo 8 — SPA-like navigation without writing a router
- WooCommerce — full integration: mini-cart drawer, cart page, shop, product, account
- Carbon Fields — theme options panel and post meta fields, no ACF needed
- Security — XML-RPC disabled, login rate limiting, HTTP headers, REST API protection
- GitHub Actions CI — automatic PHP lint + Vite build on every push
# 1. Clone into wp-content/themes/
cd wp-content/themes/
git clone https://github.com/your-org/wp-starter-tw4.git
cd wp-starter-tw4
# 2. Install JS dependencies
npm install
# 3. Start the dev server (HMR)
npm run devWordPress can run at any URL (localhost, wp.test, etc.) — Vite is configured with cors: true.
npm run buildVite outputs hashed files to dist/ and generates dist/.vite/manifest.json. PHP reads the manifest and automatically enqueues the correct versioned files.
DEV (npm run dev)
vite.config.js → writes .vite-dev with origin URL
inc/vite.php → detects .vite-dev → loads assets from localhost:5173
WordPress → <script type="module" src="http://localhost:5173/src/js/app.js">
Vite → serves file + WebSocket HMR
PROD (npm run build)
Vite → dist/.vite/manifest.json
inc/vite.php → reads manifest → <script src="/dist/js/app-[hash].js">
A single .vite-dev file determines the mode — zero WP config changes between environments.
wp-starter-tw4/
├── .github/workflows/ci.yml # PHP lint + Vite build CI
├── inc/
│ ├── vite.php # Asset loader (dev/prod)
│ ├── security.php # WordPress hardening
│ ├── helpers.php # theme_icon(), theme_breadcrumbs(), etc.
│ ├── nav-walker.php # Nav walker with Alpine.js dropdowns
│ ├── shortcodes.php # Ready-to-use shortcodes
│ ├── post-types.php # CPT scaffold (commented examples)
│ ├── woocommerce.php # Full WooCommerce integration
│ └── carbon-fields.php # Theme options and post meta fields
├── src/
│ ├── css/
│ │ ├── app.css # Tailwind v4 entry — @theme tokens + @import
│ │ ├── editor.css # Block editor styles
│ │ ├── woocommerce.css # WooCommerce overrides
│ │ └── components/ # BEM component CSS files
│ ├── js/
│ │ ├── app.js # Main entry: Alpine + Turbo boot
│ │ ├── turbo.js # Turbo lifecycle hooks + animations
│ │ ├── utils.js # JS helpers (animations, formatters)
│ │ ├── woocommerce.js # WooCommerce-specific JS entry
│ │ └── components/ # Alpine.js components
│ └── icons/ # Inline SVGs (used by theme_icon())
├── template-parts/
│ ├── blocks/ # PHP blocks (hero, cta, mini-cart, search-modal)
│ └── content/ # Content partials (card, author-box, etc.)
├── templates/woocommerce/ # WooCommerce template overrides
├── functions.php # Theme bootstrap
├── header.php / footer.php # Main layout
├── index.php / single.php / archive.php / page.php / search.php
├── theme.json # Block editor config + colour palette
├── vite.config.js
└── package.json
Define all tokens once in src/css/app.css inside @theme {}:
@theme {
--color-gold: #a0782a;
--color-ink: #1a1510;
--font-display: 'Playfair Display', Georgia, serif;
--shadow-md: 0 4px 20px rgba(26, 21, 16, 0.09);
--section-py: 6rem;
}Automatically available as:
- Tailwind utility classes:
bg-gold,text-ink,font-display,shadow-md - CSS custom properties:
var(--color-gold),var(--font-display)
| Store | Key | Description |
|---|---|---|
ui |
menuOpen |
Mobile menu state |
ui |
searchOpen |
Search modal state |
cart |
count |
Cart item count (synced with WC) |
cart |
open |
Mini-cart drawer state |
toast |
— | Toast notification queue |
confirm |
— | Confirmation dialog state |
<!-- Usage in templates -->
<button @click="$store.ui.toggleSearch()">Search</button>
<span x-show="$store.cart.count > 0" x-text="$store.cart.count"></span>modal, drawer, qty, countdown, clipboardCopy, accordion, tabs, dropdown, antiquaSearch, antiquaCart
- Mini-cart drawer with WC fragments (updates without page reload)
- Cart page with Alpine.js (quantity change, discount code)
- Template overrides: shop, product, account
- All WC default CSS disabled — replaced by
src/css/woocommerce.css - Turbo
no-cacheon cart / checkout / account pages - AJAX add-to-cart → automatically opens the cart drawer
theme_icon('arrow-right', 'w-5 h-5'); // Inline SVG from /src/icons/
theme_nav_menu('primary', [...]); // Nav with Alpine walker
theme_img($id, 'card'); // Responsive <img>
theme_breadcrumbs(); // Breadcrumbs (schema.org)
theme_post_meta(); // Date · Author · Read time
theme_categories(); // Category badge links
theme_share_buttons(); // Share FB/TW/LI/WA + copy link
class_list(['btn', 'btn-lg' => $large]); // clsx-like helper
theme_meta('field_key'); // Carbon Fields wrapper- WordPress version removed from all outputs
- XML-RPC disabled
- Login rate limiting (5 attempts / 15 min, via transients)
- Headers:
X-Content-Type-Options,X-Frame-Options,Referrer-Policy,Permissions-Policy - REST API: user enumeration blocked for unauthenticated requests
- Uploaded filenames sanitized
| Technology | Version |
|---|---|
| PHP | 8.1+ |
| WordPress | 6.4+ |
| Node.js | 20 LTS+ |
| npm | 9+ |
| WooCommerce (optional) | 8+ |
| Carbon Fields (optional) | 3+ |
Please read CONTRIBUTING.md before submitting a PR.
# Lint PHP
npm run lint:php
# Build assets
npm run buildUse Conventional Commits:
feat:, fix:, refactor:, docs:, chore:
GPL v2 or later — the same license as WordPress.
Nowoczesny starter do WordPressa — Tailwind CSS v4 · Vite 6 · Alpine.js · Hotwire Turbo · WooCommerce
Zapomnij o page builderach. wp-starter-tw4 to minimalistyczny punkt startowy do tworzenia motywów WordPress z prawdziwym nowoczesnym stackiem frontendowym — szybkim, modularnym i gotowym do produkcji od pierwszego commita.
- Tailwind CSS v4 z tokenami designu w
@theme {}— beztailwind.config.js, bez konfiguracji - Vite 6 z HMR — zmiany w CSS i JS widoczne natychmiast, bez przeładowania strony
- Alpine.js 3 — reaktywny UI (menu, drawer koszyka, modale, dropdowns) bez jQuery
- Hotwire Turbo 8 — nawigacja jak w SPA bez pisania routera
- WooCommerce — pełna integracja: mini-cart drawer, strona koszyka, sklep, produkt, konto
- Carbon Fields — panel opcji motywu i meta pól, bez ACF
- Bezpieczeństwo — XML-RPC wyłączony, rate limiting logowania, nagłówki HTTP, ochrona REST API
- GitHub Actions CI — automatyczny lint PHP + build Vite przy każdym pushu
# 1. Sklonuj do wp-content/themes/
cd wp-content/themes/
git clone https://github.com/your-org/wp-starter-tw4.git
cd wp-starter-tw4
# 2. Zainstaluj zależności JS
npm install
# 3. Uruchom dev server (HMR)
npm run devWordPress może działać pod dowolnym adresem (localhost, wp.test itd.) — Vite jest skonfigurowany z cors: true.
npm run buildVite generuje pliki z hashem do dist/ i dist/.vite/manifest.json. PHP czyta manifest i automatycznie podłącza właściwe pliki.
DEV (npm run dev)
vite.config.js → zapisuje .vite-dev z adresem origin
inc/vite.php → wykrywa .vite-dev → ładuje zasoby z localhost:5173
WordPress → <script type="module" src="http://localhost:5173/src/js/app.js">
Vite → serwuje plik + WebSocket HMR
PROD (npm run build)
Vite → dist/.vite/manifest.json
inc/vite.php → czyta manifest → <script src="/dist/js/app-[hash].js">
Jeden plik .vite-dev determinuje tryb — zero zmian w konfiguracji WP między środowiskami.
wp-starter-tw4/
├── .github/workflows/ci.yml # PHP lint + Vite build CI
├── inc/
│ ├── vite.php # Loader assetów (dev/prod)
│ ├── security.php # Hardening WordPressa
│ ├── helpers.php # theme_icon(), theme_breadcrumbs(), itp.
│ ├── nav-walker.php # Walker nawigacji z Alpine dropdowns
│ ├── shortcodes.php # Gotowe shortcody
│ ├── post-types.php # Scaffold CPT (przykłady w komentarzach)
│ ├── woocommerce.php # Pełna integracja WooCommerce
│ └── carbon-fields.php # Opcje motywu i meta pola
├── src/
│ ├── css/
│ │ ├── app.css # Entry Tailwind v4 — @theme tokens + @import
│ │ ├── editor.css # Style edytora blokowego
│ │ ├── woocommerce.css # Nadpisania WooCommerce
│ │ └── components/ # Pliki CSS komponentów BEM
│ ├── js/
│ │ ├── app.js # Entry: Alpine + Turbo boot
│ │ ├── turbo.js # Lifecycle Turbo + animacje
│ │ ├── utils.js # Helpery JS (animacje, formattery)
│ │ ├── woocommerce.js # Entry specyficzny dla WooCommerce
│ │ └── components/ # Komponenty Alpine.js
│ └── icons/ # SVG inline (używane przez theme_icon())
├── template-parts/
│ ├── blocks/ # Bloki PHP (hero, cta, mini-cart, search-modal)
│ └── content/ # Partiale treści (card, author-box itp.)
├── templates/woocommerce/ # Nadpisania szablonów WooCommerce
├── functions.php # Bootstrap motywu
├── header.php / footer.php # Główny layout
├── index.php / single.php / archive.php / page.php / search.php
├── theme.json # Konfiguracja edytora blokowego + paleta kolorów
├── vite.config.js
└── package.json
Wszystkie tokeny definiujesz raz w src/css/app.css w bloku @theme {}:
@theme {
--color-gold: #a0782a;
--color-ink: #1a1510;
--font-display: 'Playfair Display', Georgia, serif;
--shadow-md: 0 4px 20px rgba(26, 21, 16, 0.09);
--section-py: 6rem;
}Automatycznie dostępne jako:
- Klasy Tailwind:
bg-gold,text-ink,font-display,shadow-md - CSS custom properties:
var(--color-gold),var(--font-display)
| Store | Klucz | Opis |
|---|---|---|
ui |
menuOpen |
Stan mobilnego menu |
ui |
searchOpen |
Stan modala wyszukiwania |
cart |
count |
Liczba produktów w koszyku (sync z WC) |
cart |
open |
Stan drawera mini-cart |
toast |
— | Kolejka powiadomień toast |
confirm |
— | Stan dialogu potwierdzenia |
<!-- Użycie w szablonach -->
<button @click="$store.ui.toggleSearch()">Szukaj</button>
<span x-show="$store.cart.count > 0" x-text="$store.cart.count"></span>modal, drawer, qty, countdown, clipboardCopy, accordion, tabs, dropdown, antiquaSearch, antiquaCart
- Drawer mini-cart z fragmentami WC (aktualizacja bez przeładowania strony)
- Strona koszyka z Alpine.js (zmiana ilości, kod rabatowy)
- Nadpisania szablonów: sklep, produkt, konto
- Domyślny CSS WooCommerce całkowicie wyłączony — zastąpiony przez
src/css/woocommerce.css - Turbo
no-cachena stronach koszyk / checkout / konto - AJAX add-to-cart → automatycznie otwiera drawer koszyka
theme_icon('arrow-right', 'w-5 h-5'); // Inline SVG z /src/icons/
theme_nav_menu('primary', [...]); // Nav z Alpine walker
theme_img($id, 'card'); // Responsywny <img>
theme_breadcrumbs(); // Okruszki nawigacyjne (schema.org)
theme_post_meta(); // Data · Autor · Czas czytania
theme_categories(); // Kategorie jako badge
theme_share_buttons(); // Udostępnianie FB/TW/LI/WA + kopiuj link
class_list(['btn', 'btn-lg' => $large]); // Helper clsx-like
theme_meta('klucz_pola'); // Wrapper Carbon Fields- Wersja WordPressa usunięta ze wszystkich outputów
- XML-RPC wyłączone
- Rate limiting logowania (5 prób / 15 min, przez transients)
- Nagłówki:
X-Content-Type-Options,X-Frame-Options,Referrer-Policy,Permissions-Policy - REST API: blokada enumeracji użytkowników dla niezalogowanych
- Sanitizacja nazw uploadowanych plików
| Technologia | Wersja |
|---|---|
| PHP | 8.1+ |
| WordPress | 6.4+ |
| Node.js | 20 LTS+ |
| npm | 9+ |
| WooCommerce (opcjonalnie) | 8+ |
| Carbon Fields (opcjonalnie) | 3+ |
Przeczytaj CONTRIBUTING.md przed wysłaniem PR.
# Lint PHP
npm run lint:php
# Build assetów
npm run buildCommity w formacie Conventional Commits:
feat:, fix:, refactor:, docs:, chore:
GPL v2 lub nowsza — ta sama licencja co WordPress.