Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Adding theme options & snippets

Koen edited this page Aug 1, 2019 · 3 revisions

Sometimes you need to add an option or a small snippet which can't be placed in specific place. That's were ACF options pages come into play. We have a default options page called Theme Options.

It's possible to add more top level pages, but usually adding subpages to the existing one will suffice.

Add an options page

  • Go to Grrr\Acf\Options\Theme
  • Add a subpage
  • Create a corresponding ACF field group linked to that subpage (called Options › <Name>)
  • Make

Add a snippet

Always try to add snippet as close to the source as possible. If they are part of a template or post type, add them there. If that's not possible, resort to the snippets in the Theme Options.

  • Go to Custom Fields and edit Options › Snippets
  • Add the new snippet (possibly to a tab if appropriate)
  • Make sure fields are prefixed with snippets_, and possibly the group: snippets_<group>_<name>

Twig helper functions

There are a few custom helper functions usable in the Twig templates. Underscore can be left out, since they'll be added automatically.

Get any option from a group:

{{ option('title', 'cookie bar') }}

Get any snippet:

{{ snippet('footer copyright label') }}