-
Notifications
You must be signed in to change notification settings - Fork 18
Theme Functionality
While main code base is object-oriented, we still need simple functions for trivial things.
This functionality is placed inside inc folder. By default we have 3 files inside:
helpers.phphooks.phptemplate-funcs.php
Helpers are simple functions, which perform some simple data processing. This can be some data formatters, format adapters or similar.
Example: we have product catalog on our site (no e-commerce) and we need have a lot of product banners
over the site. Each banner print price along all other information and you want to be sure it has the
same format like "{currency} {amount with 2 digits}". You can create simple helper function {prefix}_price(),
and use it inside the templates
Major of hooks are registered inside the app. However there are some hooks, which are not important or
has very generic definition. We place such hooks inside this file.
Example: Body class adjustment based on some logic.
Example: Excerpt length hook.
The main part of the Wordpress templates is The Loop. Functions, which generates some content for post/pages or custom post types are added here.
Example: {prefix}_posted_on() printed formatted post date
Available functions by default:
| Function | Description |
|---|---|
| {prefix}_posted_on() | Print formatted post date and post author |
| {prefix}_entry_footer() | Print formatted post categories, tags and other meta info |