我已经设置了一个高级自定义字段项目,以在自定义帖子类型的每个类别和存档的顶部显示特色图像、描述等。
自定义帖子类型和分类是
$event_args = array(
'has_archive' => 'news-events',
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $event_rewrite,
'capability_type' => 'post',
);
register_post_type( 'events', $event_args );
register_taxonomy( 'event_category', array( 'events' ), $events_args );
在 archive-events.php 我有
$context['pagination'] = Timber::get_pagination();
$context['title'] = 'Archive Tours';
$context['posts'] = Timber::get_posts();
$content['events'] = Timber::get_terms('event_category');
Timber::render($templates, $context);
在树枝文件中
<div class="col-sm-12 col-md-12">
<article class="post post-container">
<div class="entry-header">
<div class="post-thumb thumb">
{% if events.featured_event_image %}
<img src="{{TimberImage(events.featured_event_image).src}}" alt="{{ events.featured_event_title }}"
class="img-responsive" />
{% else %}
{# TODO: replace this with something we serve. #}
<img src="http://placehold.it/500x340" alt="Default Thumbnail" class="img-responsive">
{% endif %}
</div>
</div>
<div class="sa_blog_content">
<div class="sa_blog_center">
<h4 class="sa_blog_title"><a target="_self" title="{{ events.featured_event_title }}" href="#">{{
events.featured_event_title }}</a></h4>
<div class="meta">
<span><time datetime="{{post.post_date|date('F j, Y')}}">{{post.post_date|date('F j, Y')}}</time></span>
<span>359 Views</span>
</div>
</div>
{{ events.featured_event_summary }}
<div class="tagcloud">
{% for term in post.terms('featured_event_tags') %}
<span><a href="{{post.term.link}}" title="{{post.term.name}}">{{post.term.name}}</a></span>
{% endfor %}
</div>
</div>
</article>
</div>
然而,存档或类别页面中没有我的客户字段可用。任何人都可以提出解决这个问题的方法。提前致谢...