我正在试验Sage WordPress入门主题的版本9, 该主题使用Laravel Blade作为构建WP模板的模板引擎。
我的问题是:Sage 9是否使Blade的$ loop变量在视图的循环内可用?
例如, 给定文件/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的限制?
#1【Laravel Blade的$loop变量在Sage 9视图中可用吗()】$ loop变量将在@foreach()循环内可用
@foreach ($users as $user)
@if ($loop->
first)
// This is the first iteration.
@endif
@endforeach
推荐阅读
- 有关访问Ajax所需文件以传递给URL进行Ajax调用的问题
- 是否可以重新注册未注册的WordPress侧边栏()
- 是否可以在Vue2 Js或React.Js中制作WordPress主题()
- 是否可以从其他服务器托管WordPress数据库
- 在WordPress的出现我的主题没有背景描述它
- 在WordPress中如何以正确的方式编写post mata( [关闭])
- 在woocommerce中,如何在结帐页面上添加参与者列表并在订单详细信息页面中显示
- Linux中dhcp分配地址
- grep文本处理和脚本