如何用木材制作职位类别过滤器?

对于WordPress网站中的博客,我只想显示与“过滤器”中所选类别相对应的帖子,但我不知道是否必须使用树枝和木材,或者是否必须使用Javascript。

这是我的代码示例:

blog.php

$context = Timber::context();

global $paged;
$pagination = $paged ?? ! $paged ?: 1;

$args = [
    'post_type'      => 'post','posts_per_page' => 12,'paged'          => $paged,'orderby'        => [
        'date' => 'DESC'
    ]
];

$context['articles'] = new Timber\PostQuery($args);

// To get categories of each posts
$context['categories'] = Timber::get_terms('category');

Timber::render( [ 'blog.html.twig' ],$context );

blog.twig.html

{# FILTERS #}
<div class="filter">
 {% for category in categories %}
   <div class="cta">
    <button type="submit" class="cta__link cta__link--white" 
      id="{{ category.id }}">
        {{ category.title }}
    </button>
   </div>
 {% endfor %}
</div>

{# ARTICLE #}
<div class="section--articles section__wrapper">
  {% for article in articles %}
    <div class="article">
      {# MY ARTICLE #}
    </div>
  {% endfor %}
</div>

有人可以帮我解决这个问题吗?我不怎么开始... 谢谢

xiaoman1987 回答:如何用木材制作职位类别过滤器?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3151732.html

大家都在问