When building a theme, it is quite handy to be able to store some pieces of often used code in a separate file. Typically a page's header, the navigation and a footer are basically the same across all templates. It is therefore good practice to move all these code snippets to different files. For example, editing the footer then is just the matter of changing one file instead of applying these changes manually to every template.
The usage of Includes is very similar to the variable's one. Instead of a variable,
@i() expects a file path.
The specified file path must always be relative to the including template file. Assuming there is a
header.php in a subdirectory called
elements, the markup would be:
Note that it is also possible to nest includes for even more flexibility. When nesting includes, the file paths are always relative to the including file - not the main template file. For example, to include a file called
navigation.php to the
header.php within the same subdirectory, the path looks just like this: