---
agentTools:
  projectIndex: https://olympus.readme.io/llms.txt
---

# Create a custom menu

With a tiny example :)

[block:api-header]
{
  "type": "basic",
  "title": "1. Make the Tea Theme Options working"
}
[/block]

As we said before:

[block:code]
{
  "codes": [
    {
      "code": "<?php\n\nuse crewstyle\\TeaThemeOptions\\TeaThemeOptions;\n\n//Include composer autoload\nrequire_once __DIR__.'/vendor/autoload.php';\n\n//Instanciate a new TeaThemeOptions\n$tea = new TeaThemeOptions();",
      "language": "php"
    }
  ]
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "2. Define what you want"
}
[/block]

Specify your wanted components:

[block:code]
{
  "codes": [
    {
      "code": "<?php\n\n//Define an example page and build menu\n$tea->addMenu(array(\n    'title' => __('Example page'),\n    'name' => __('Example page'),\n    'slug' => 'examplepage'\n));\n\n//Build contents with a filter composed by `tto_template_%s_contents`\n//replacing `%s` by the slug's page\nadd_filter('tto_template_examplepage_contents', 'tto_examplepage');\nfunction tto_examplepage($contents)\n{\n\treturn array(\n    array(\n      'type' => 'heading',\n      'title' => __('Header.')\n    ),\n    array(\n      'type' => 'radio',\n      'title' => __('Fix the main menu bar to the top of the screen?'),\n      'id' => 'header_menu_position',\n      'default' => 'yes',\n      'options' => array(\n        'yes' => __('Yes'),\n        'no' => __('No')\n      )\n    ),\n    array(\n      'type' => 'heading',\n      'title' => __('Footer.')\n    ),\n    array(\n      'type' => 'text',\n      'title' => __('Copyright.'),\n      'id' => 'footer_copyright',\n      'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')\n    ),\n  );\n}",
      "language": "php"
    }
  ]
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "3. Build the menu"
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "<?php\n\n//Build menus\n$tea->buildMenus();",
      "language": "php"
    }
  ]
}
[/block]

[block:api-header]
{
  "type": "basic",
  "title": "4. All in one"
}
[/block]

Here is a complete snapshot of what you have to do. Remember to make all these modifications in your `functions.php` theme file.

[block:code]
{
  "codes": [
    {
      "code": "<?php\n\nuse crewstyle\\TeaThemeOptions\\TeaThemeOptions;\n\n//Include composer autoload\nrequire_once __DIR__.'/vendor/autoload.php';\n\n//Instanciate a new TeaThemeOptions\n$tea = new TeaThemeOptions();\n\n//Define an example page and build menu\n$tea->addMenu(array(\n    'title' => __('Example page'),\n    'name' => __('Example page'),\n    'slug' => 'examplepage'\n));\n\n//Build contents with a filter composed by `tto_template_%s_contents`\n//replacing `%s` by the slug's page\nadd_filter('tto_template_examplepage_contents', 'tto_examplepage');\nfunction tto_examplepage($contents)\n{\n\treturn array(\n    array(\n      'type' => 'heading',\n      'title' => __('Header.')\n    ),\n    array(\n      'type' => 'radio',\n      'title' => __('Fix the main menu bar to the top of the screen?'),\n      'id' => 'header_menu_position',\n      'default' => 'yes',\n      'options' => array(\n        'yes' => __('Yes'),\n        'no' => __('No')\n      )\n    ),\n    array(\n      'type' => 'heading',\n      'title' => __('Footer.')\n    ),\n    array(\n      'type' => 'text',\n      'title' => __('Copyright.'),\n      'id' => 'footer_copyright',\n      'default' => __('&copy; your_name, all rights reserved ~ Built with ♥ with the Tea Theme Options!')\n    ),\n  );\n}\n\n//Build menus\n$tea->buildMenus();",
      "language": "php",
      "name": "functions.php"
    }
  ]
}
[/block]

Pay attention: do not hesitate to make conditions on what you need in your backend panel versus what you need in your frontend website.