PHP Laravel Blade @include 将数据传递到 WordPress 查询中

PHP Laravel Blade @include pass data into WordPress query

我正在使用 Sage 9 WordPress 入门主题。https://github.com/roots/sage

在 Laravel Blade 中包含模板并传递一些数据后。

@include ('partials.filter-archive', ['taxonomy' => 'project-type'])

如何在我的模板中使用它 partials.filter-archive ?? {{ $taxonomy }} 似乎不起作用:(

@php
  $terms = get_terms(array(
    'taxonomy' => {{ $taxonomy }},
    'orderby' => 'menu_order',
  ));
  print_r($terms);
@endphp

试一次

@include ('partials.filter-archive', ['taxonomy' => "project-type"]);

并尝试在调用 wp 函数之前执行此操作 {{ $taxonomy }},并检查它是否被打印

我解决了

我实际上可以在 partials.filter-archive 中简单地执行此操作,这对我有用。

$terms = get_terms(array(
    'taxonomy' => $taxonomy,
    'orderby' => 'menu_order',
  ));

print_r($terms);