dongzhuo1958
2017-06-06 04:00
浏览 34
已采纳

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

I'm using Sage 9 WordPress starter theme.https://github.com/roots/sage

After include the template in Laravel Blade and pass some data.

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

How could I use it in my template partials.filter-archive ?? {{ $taxonomy }} doesn't seem to work :(

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

图片转代码服务由CSDN问答提供 功能建议

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

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

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

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

  @php 
 $ terms = get_terms(array(
'taxonomy'=&gt; {{$ taxonomy}},
'orderby'=&gt;'menu_order'  ,
)); 
 print_r($ terms); 
 @ endphp 
   
 
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dqajyxqem115006813 2017-06-06 04:16
    已采纳

    I solved it

    I can actually simply just do this in partials.filter-archive, that worked for me.

    $terms = get_terms(array(
        'taxonomy' => $taxonomy,
        'orderby' => 'menu_order',
      ));
    
    print_r($terms);
    
    点赞 打赏 评论
  • doutangshuan6473 2017-06-06 04:05

    try this once

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

    and try to do this {{ $taxonomy }} before calling wp function, and check if its getting printed

    点赞 打赏 评论

相关推荐 更多相似问题