Home » Development » PHP » TWIG » Seite 2
TWIG allows you to use regular expressions within its templates, this makes it possible to easily check if a post is sticky in Timber for WordPress.
Comparisons in TWIG
This is the template that is called within the loop on the index.twig to show each post.
The post.class holds the full set of classes assigned to a post, which includes the class „sticky“. We do the match magic and you can use that to style your sticky posts differently ;)
„Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the Twig Template Engine separate from your PHP files.
This cleans-up your theme code so, for example, your php file can focus on being the data/logic, while your twig file can focus 100% on the HTML and display.“
Twig is a modern template engine for PHP