我在我的函數文件中添加了co作者站點提供的函數posting_on。常規作者和合作作者在單個頁面上顯示,但我似乎無法在作者檔案頁面上工作。當我點擊共同作者的鏈接時,它會轉到合作作者的正確網址,但顯示的內容是針對正常作者的。我已經看過共同作者的github問題,但對如何在我的樹枝中實現合作作者感到困惑。Timber,Twig:Getting Co作者在作者檔案頁面上顯示
我確定有一些我需要的$上下文,但我真的不確定在那裏添加什麼。
的single.php
<span class="author"><a href="{{post.author.link}}" rel="author">
{{function('name_posted_on')}}</a>
</span>
我有一個author.php文件
$context = Timber::get_context();
$args = 'post_type=post&numberposts=2';
$context['posts'] = Timber::get_posts($args);
Timber::render(array('author.twig'), $context);
在我author.twig文件:
<div class="col-md-12">
//I need the author or co author to be displayed in the h3 and their posts in the loop
<h3>Latest From {{posts.author.first_name}} {{posts.author.last_name}}</h3>
</div>
{% for post in posts %}
<article class="latest-article-widget col-md-6">
{% block author %}
{% if post.get_thumbnail %}
<img src="{{post.thumbnail.src}}" class="img-responsive" />
{% endif %}
<div class="author">
<span>By:</span>
<a href="" rel="author">{{post.author.first_name}} {{post.author.last_name}}</a>
</div>
<h1><a href="{{post.link}}">{{post.title}}</a></h1>
{% for item in post.get_field('post_or_page_content') %}
<p>{{item.standard_text_content|excerpt(25)}} <a href="{{post.link}}"></a></p>
{% endfor %}
{% endblock %}
</article>
{% endfor %}
啊呀。我從另一個開發者繼承了這個項目。我假設他們應該在文章元素中使用標題元素,然後添加標題標籤。據我瞭解。像section> header> h1 – lnickel
@lnickel這沒關係。在頭文件中嵌套H1也是文檔模型的一部分。解決方法是根據文檔模型不編碼。這基本上意味着你應該像我們以前那樣做。就標題而言,它意味着每頁僅使用一個H1,而不是跳過標題級別並嵌套標題,以便在僅查看標題(如輔助技術的人員)時提供頁面結構。 – Gchtr
Bueno!感謝您的澄清! – lnickel