giuseppe-trisciuoglio/developer-kit / plugins/developer-kit-php/skills/wordpress/wordpress-sage-theme
wordpress-sage-theme
VerifiedProvides WordPress theme development patterns using Sage (roots/sage) framework. Use when creating, modifying, or debugging WordPress themes with Sage, including (1): creating new Sage themes from scratch, (2): setting up Blade templates and components, (3): configuring build tools (Vite, Bud), (4): working with WordPress theme templates and hierarchy, (5): implementing ACF fields integration, (6): theme customization and asset management.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.6 KB |
| assets/starter-layout.blade.php | script | 549 B |
| assets/starter-page.blade.php | script | 1.6 KB |
| references/acf.md | markdown | 9.5 KB |
| references/blade.md | markdown | 5.1 KB |
| references/bud.md | markdown | 5.0 KB |
| references/sage.md | markdown | 2.4 KB |
references/blade.md
View on GitHub# Blade Templates Reference
Complete reference for Blade templating in Sage WordPress themes.
## Directives Reference
### Template Inheritance
**`@`extends**: Inherit from a layout
```blade
@extends('layouts.app')
```
**`@`section**: Define content section
```blade
@section('content')
<h1>Page Content</h1>
@endsection
```
**`@`yield**: Display content section
```blade
@yield('content')
@yield('content', 'Default content if not provided')
```
### Conditionals
**`@`if/`@`else/`@`elseif/`@`endif**
```blade
@if (condition)
<p>True</p>
@elseif (other_condition)
<p>Other</p>
@else
<p>False</p>
@endif
```
**`@`unless**: Negative if
```blade
@unless ($user->logged_in)
<a href="/login">Login</a>
@endunless
```
**`@`isset/null**: Check variable existence
```blade
@isset($variable)
{{ $variable }}
@endisset
@empty($collection)
<p>No items</p>
@endempty
```
**`@`auth/`@`guest**: User authentication
```blade
@auth
<a href="/dashboard">Dashboard</a>
@endauth
@guest
<a href="/login">Login</a>
@endguest
```
### Loops
**`@`while**: WordPress loop
```blade
@while (have_posts())
@php the_post() @endphp
<h2>{{ the_title() }}</h2>
@endwhile
```
**`@`foreach**: Iterate arrays
```blade
@foreach ($items as $item)
<li>{{ $item->name }}</li>
@endforeach
```
**`@`for**: Standard for loop
```blade
@for ($i = 0; $i < 10; $i++)
<span>{{ $i }}</span>
@endfor
```
**`@`break/`@`continue**: Loop control
```blade
@foreach ($items as $item)
@if ($item->skip)
@continue
@endif
{{ $item->name }}
@if ($item->last)
@break
@endif
@endforeach
```
### Includes
**`@`include**: Include template
```blade
@include('components.card')
```
**`@`includeIf**: Include if exists
```blade
@includeIf('components.optional')
```
**`@`includeWhen**: Include conditionally
```blade
@includeWhen($condition, 'components.featured')
```
**`@`includeIf**: With variables
```blade
@include('components.button', ['text' => 'Click', 'url' => '/page'])
```
### Components
**Anonymous Components** (`resources/views/components/alert.blade.php`):
```blade
@props(['type' => 'info', 'message' => ''])
<div class="alert alert-{{ $type }}">
{{ $message }}
</div>
```
**Usage**:
```blade
<x-alert type="warning" message="Warning message" />
```
**Indexed Components** (`resources/views/components/button.blade.php`):
```blade
@props(['variant' => 'primary'])
<button class="btn btn-{{ $variant }}">
{{ $slot }}
</button>
```
**Usage**:
```blade
<x-button variant="secondary">
Click Me
</x-button>
```
**Dynamic Components**:
```blade
@php $component = 'button' @endphp
<x-dynamic-component :component="$component" :variant="'primary'" />
```
### Directives
**`@`php**: Execute PHP
```blade
@php
$data = get_field('data');
$formatted = format_data($data);
@endphp
```
**`@`verbatim**: Disable Blade parsing
```blade
@verbatim
{{ This won't be parsed }}
@endverbatim
```
**`@`once**: Execute once per rendering
```blade
@once
<script src="https://cdn.example.com/widget.js"></script>
@endonce
```
**`@`csrf**: CSRF token (rarely used in WP)
```blade
@csrf
```
**`@`method**: Form method spoofing
```blade
@method('PUT')
```
## WordPress Functions in Blade
### Common Functions
```blade
{{ the_title() }} // Post title
{{ the_content() }} // Post content
{{ the_excerpt() }} // Post excerpt
{{ the_permalink() }} // Post URL
{{ the_post_thumbnail_url() }} // Featured image URL
{{ the_date() }} // Post date
{{ the_author() }} // Author name
{{ the_category() }} // Categories
{{ the_tags() }} // Tags
```
### Conditional Tags
```blade
@if (is_front_page()) @endif
@if (is_home()) @endif
@if (is_single()) @endif
@if (is_page()) @endif
@if (is_category()) @endif
@if (is_archive()) @endif
@if (is_search()) @endif
@if (is_404()) @endif
```
### Helper Functions
```blade
{{ get_template_directory_uri() }} // Theme URL
{{ get_stylesheet_directory_uri() }} // Child theme URL
{{ home_url('/') }} // Site URL
{{ site_url('/') }} // Site URL
{{ wp_get_attachment_url($id) }} // Attachment URL
```
## Common Patterns
### Post Loop with Pagination
```blade
@extends('layouts.app')
@section('content')
<div class="posts">
@while (have_posts())
@php the_post() @endphp
@include('components.post-card')
@endwhile
</div>
{{ the_posts_pagination() }}
@endsection
```
### Sidebar Conditional
```blade
@if (is_active_sidebar('sidebar'))
<aside class="sidebar">
{{ dynamic_sidebar('sidebar') }}
</aside>
@endif
```
### Menu Rendering
```blade
@if (has_nav_menu('primary'))
<nav class="primary-nav">
{{ wp_nav_menu([
'theme_location' => 'primary',
'container' => false,
'menu_class' => 'nav-menu'
]) }}
</nav>
@endif
```
## Output Escaping
**{{ }}**: Auto-escaped (safe for user content)
```blade
{{ $user_input }}
```
**{!! !!}**: Unescaped (use with caution)
```blade
{!! $html_content !!}
```
**`@`verbatim**: Multiple unescaped lines
```blade
@verbatim
<div class="example">
{{ This won't be escaped }}
</div>
@endverbatim
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |