Displaying The Most Popular Questions

Displaying the most popular questions on your homepage is a great way to make sure that your user find their question just a bit faster. This 'just a bit faster' might mean the difference from a user coming to your knowledge base to find an answer and not coming.

We have a predefined variable specially made for this feature. You can do this using the variable top_questions inside the for loop, that will display a specific number of top questions. Below is an example showing how to implement it:

{% for question in top_questions limit: 5 %}
 <h4><a href="{{ question.url }}">{{ question.name }}</a></h4>
 <span>{{ question.category.name }}</span>
{% endfor %}

As you can see, we used the top_questions variable with the for loop to repeat questions five times. We limited this for loop to five times using limit:(number).

If you want to see a list of all variables, please click on this link where you can see all our variables which you can use for customization.

Was this article helpful?