skip to main content

Ryan Hettler

Enable Disqus with Timber Starter Theme

January 31, 2015

To enable Disqus with Timber Starter Theme in WordPress, install and enable the Disqus Commenting System plugin and add this simple line of code in the single.twig file:

{{ function('comments_template') }}

A pretty straightforward and simple answer. This is Timber’s way of  bringing in WordPress functionality. According to Timber WP Integration page, this can only work in a single.twig file and it – unfortunately – can’t work in loop.

Maybe WordPress’s default comment system is desirable. With Timber, you can customize the comment section anyway you want:

single.twig

{# single.twig file #}
{{ comment_form }}

{% for cmt in post.get_comments() %}
   {% include "comment.twig" with {comment:cmt} %}
{% endfor %}

comment.twig

{# comment.twig #}

<div class="blog-comment {{comment.comment_type}}" id="blog-comment-{{comment.ID}}">
   <h5 class="comment-author">{{comment.author.name}} says</h5>
   <div class="comment-content">{{comment.comment_content|wpautop}}</div>
</div>

To disable comments in wordpress completely, there are a couple of lines of code you can insert into your functions.php file.

Resources: