-
Notifications
You must be signed in to change notification settings - Fork 1
3. Adding Menus and Custom Post Types
The App.php
file located at /web/app/themes/theme/app/App.php
is responsible for registering menus and custom post types (CPTs) in the theme. It uses two theme-defined services: MenuBuilder
and CPTBuilder
, making it easy to manage these elements directly from a single location.
The App.php
class uses the MenuBuilder
and CPTBuilder
services to simplify menu and CPT creation. Here's how it works:
The MenuBuilder
service allows you to easily define and register WordPress menus. In this example, two menus are registered:
$menuBuilder
->addMenu('primary', 'Primary Navigation')
->addMenu('footer', 'Footer Navigation');
The CPTBuilder service helps you create custom post types without needing to write extensive code in your theme files. Although it’s currently commented out, the following example shows how a custom post type can be easily added:
// $cptBuilder
// ->addCPT('Employee', 'Employees');
This would register a custom post type called Employee, which would be displayed as Employees in the WordPress admin panel.