Latest & Popular Posts
What does the Latest and Most Popular Posts do?
Showing the latest (most recent) and popular (most viewed) posts/articles is a great way to give the first time visitor a sampling (or teaser) for the content the site provides. For returning visitors, the latest posts/articles let the visitor know what is new on the site.
These widgets or plugins as they are commonly referred to are designed to entice the visitor to click through the Home page and interact with the content in the site. They do what they are intended to do, but at a cost. And that cost is additional resources which cause page load time increase. The worst part is a majority of them add this load time to every page, whether or not the teasers are shown.
Prebuilt Elements and Components: Timber-Boot comes with 3 variations of teaser components:
- Latest – shows the most recent posts/articles/news
- Most Popular – shows the posts/articles/news with the most views
- Most Popular by Category – same as above but for a particular category
The function finds the articles that meat the criteria and then sends it to a customized twig template. Instead of rendering this on each page, the template is compiled and saved to a variable in the cache.
This variable is used to render the posts. This means no additional calls to the database or unnecessary libraries consuming resources. The result is a minimal amount of resources consumed and a minimal effect on page performance.
Admin Interface: The admin console controls the activation of 1, 2, or all 3 components. The number of teasers to show and the title for the teaser section are also set here.
In the page/post settings, you enable which, if any, teasers to show. For example, on the home page, you can enable the latest and most popular components. On the individual post/pages, you can show the most popular articles for the category the post is in.