【发布时间】:2023-12-25 14:20:02
【问题描述】:
我正在试验第 9 版 Sage WordPress 入门主题,它使用 Laravel Blade 作为模板引擎来构建 WP 模板。
我的问题是:Sage 9 是否使 Blade's $loop variable 在视图中的循环内可用?
例如,给定文件/my_theme/resources/views/archive.blade.php:
1 @extends('layouts.app')
2
3 @section('content')
4 @include('partials.page-header')
5
6 @if (!have_posts())
7 <div class="alert alert-warning">
8 {{ __('Sorry, no results were found.', 'sage') }}
9 </div>
10 {!! get_search_form(false) !!}
11 @endif
12
13 @while (have_posts()) @php(the_post())
14
15 @include('partials.content-'.get_post_type())
16 @endwhile
17
18 {!! get_the_posts_navigation() !!}
19 @endsection
我想在第 14 行插入以下内容:
@if ($loop->first)
// Do stuff on first iteration
@endif
但是$loop 是未定义的。
我是否遗漏了什么,或者这是目前 Sage 9 的限制?
【问题讨论】:
标签: php wordpress loops wordpress-theming blade