A modern WordPress theme starter with TypeScript, SCSS, Tailwind CSS, and Carbon Fields support.
- 🎨 Modern Build System - TypeScript, SCSS, and Tailwind CSS compilation
- 🚀 SPA-like Navigation - Smooth page transitions without full reload
- 📦 Carbon Fields - Advanced custom fields and theme options
- ✨ Code Quality - ESLint, Stylelint, and Prettier configured
- 🔧 Developer Friendly - Hot reloading, source maps, and WordPress stubs
- Node.js (v20.9.0 or higher)
- npm or yarn
- PHP 7.4 or higher
- Composer
- Local WordPress development environment
cd wp-content/themes/
git clone [repository-url] wp-theme-starter
cd wp-theme-starter# Install Node dependencies
npm install
# Install PHP dependencies (Carbon Fields)
composer install# Start development mode with file watching
npm run devThis will watch and compile:
- TypeScript files from
assets/ts/→assets/dist/js/bundle.js - SCSS files from
assets/scss/→assets/dist/css/stylesheet.css - Tailwind CSS →
assets/dist/css/tailwind.css
# Create optimized production build
npm run buildThis will:
- Clean the
assets/dist/directory - Compile and minify all assets
- Generate source maps for debugging
| Command | Description |
|---|---|
npm run dev |
Start development mode with file watching |
npm run build |
Production build with minification |
npm run lint |
Run all linters (TypeScript and SCSS) |
npm run lint:fix |
Auto-fix linting issues |
npm run lint:ts |
Lint TypeScript files only |
npm run lint:scss |
Lint SCSS files only |
npm run format |
Format all files with Prettier |
npm run format:check |
Check if files need formatting |
wp-theme-starter/
├── assets/
│ ├── ts/ # TypeScript source files
│ │ └── main.ts # Main navigation system
│ ├── scss/ # SCSS source files
│ │ ├── stylesheet.scss
│ │ ├── _main.scss
│ │ └── tailwind.css
│ ├── dist/ # Compiled assets (gitignored)
│ │ ├── css/
│ │ └── js/
│ └── [fonts|images|js]/ # Static assets
├── custom-posts/ # Custom post type definitions
│ └── team.php
├── parts/ # Template parts
│ └── nav.php
├── vendor/ # Composer dependencies (gitignored)
├── functions.php # Theme setup and configuration
├── carbon.php # Carbon Fields initialization
└── [WordPress theme files]
- TypeScript: Create modules in
assets/ts/- they'll be bundled automatically - Styles: Add SCSS partials to
assets/scss/and import them in main files - Tailwind: Use utility classes directly in PHP templates
- Custom Fields: Use Carbon Fields in
carbon.phpfor theme options
- Create a new file in
custom-posts/directory - Follow the pattern in
team.php:
register_post_type('your_post_type', [
'labels' => [...],
'public' => true,
'supports' => ['title', 'thumbnail', 'custom-fields'],
// ... other options
]);- Include the file in
functions.phpor use autoloading
Add custom fields to your theme options or post types:
use Carbon_Fields\Container;
use Carbon_Fields\Field;
Container::make('theme_options', __('Theme Options'))
->add_fields([
Field::make('text', 'crb_text', 'Text Field'),
// Add more fields
]);The project uses:
- ESLint for TypeScript/JavaScript
- Stylelint for SCSS/CSS
- Prettier for code formatting
Run linters before committing:
npm run lint
npm run format:checkFor VS Code with Intelephense:
- WordPress stubs are included via Composer
- Configuration in
.vscode/settings.jsonandintelephense.config.json - WordPress functions will be recognized after restarting VS Code
| File | Purpose |
|---|---|
webpack.config.js |
TypeScript bundling configuration |
tailwind.config.js |
Tailwind CSS customization |
tsconfig.json |
TypeScript compiler options |
.eslintrc.json |
ESLint rules for TypeScript |
.stylelintrc.json |
Stylelint rules for SCSS |
.prettierrc.json |
Code formatting rules |
postcss.config.js |
PostCSS plugins configuration |
- Restart VS Code after initial setup
- Ensure
composer installhas been run - Check that Intelephense extension is installed
- Clear
node_modulesand reinstall:rm -rf node_modules && npm install - Ensure Node version is 20.9.0 or higher:
node --version - Check for TypeScript errors:
npm run lint:ts
- Ensure
npm run devis running - Check that compiled files exist in
assets/dist/ - Clear browser cache or use incognito mode
[Your License Here]
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Run linters and fix issues (
npm run lint:fix) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request