> For the complete documentation index, see [llms.txt](https://whoisandywhite.gitbook.io/porterwp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://whoisandywhite.gitbook.io/porterwp/getting-started/directory-structure.md). Agents can also search and read this documentation through its [MCP server](https://whoisandywhite.gitbook.io/porterwp/~gitbook/mcp).

# Directory structure

PorterWP keeps its theme-specific configuration, PHP and custom blocks inside a `porter/` directory in the active theme. Theme source and compiled assets normally live in the theme-root `assets/` directory. The default layout is:

```
my-theme/
├── porter/
│   ├── config/
│   │   ├── porter.json
│   │   ├── blocks.json
│   │   ├── posttypes.json
│   │   ├── taxonomies.json
│   │   └── acf.json
│   ├── blocks/
│   │   ├── _block-base/        # Optional public-scaffold template
│   │   ├── components/         # Example configured scan directory
│   │   └── make.sh             # Optional scaffold helper
│   └── inc/
│       ├── first/              # PHP loaded before normal include folders
│       ├── traits/             # PHP loaded before normal include folders
│       ├── block/
│       │   ├── patterns/       # Pattern content; excluded from PHP autoload
│       │   ├── styles/css/     # Custom block-style CSS
│       │   └── core/styles/css/ # CSS merged into theme.json core styles
│       ├── posttypes/{slug}/icon.svg
│       └── config.json         # Optional include-cache metadata
├── assets/                     # Theme source or compiled assets
├── functions.php
├── style.css
└── theme.json
```

All paths are relative to the active stylesheet directory, so child themes use their own `porter/` directory.

## Configuration files

| File              | Purpose                                                                             |
| ----------------- | ----------------------------------------------------------------------------------- |
| `porter.json`     | Theme support, frontend/editor assets and premium feature switches.                 |
| `blocks.json`     | Block discovery, categories, styles, patterns and unregister/dequeue rules.         |
| `posttypes.json`  | Custom post-type registration and optional local ACF field groups.                  |
| `taxonomies.json` | Custom taxonomy registration and post-type relationships.                           |
| `acf.json`        | ACF option pages and standalone local field groups, gated by their individual APIs. |

See the [Configuration Files Index](https://whoisandywhite.gitbook.io/porterwp/getting-started/configuration-files.md) for their schemas.

## Custom block directories

The default custom-block root is `porter/blocks`. Override it with `blocks.settings.path` in `blocks.json` or the `porter_block_path` filter.

When `blocks.settings.folders` is empty, PorterWP scans the block root. When it contains folders, PorterWP scans those directories instead. Each configured directory is scanned one level deep for block folders containing `block.json`.

Custom block registration requires premium code and the ACF PRO APIs used by PorterWP. See [Custom Blocks](https://whoisandywhite.gitbook.io/porterwp/features/blocks.md).

## The `inc/` PHP autoloader

PorterWP scans `porter/inc/` recursively and loads readable `.php` files on `init` at priority 3.

Filters that change the include root, exclusions, or load-first names must be registered in the theme's `functions.php` or earlier. A callback inside `porter/inc/` is too late to control the scan that loads it. The same placement rule applies to `porter_wp_config_filepath` when early consumers such as theme-support setup must see the alternate config directory.

* `first` and `traits` are promoted ahead of other entries when present.
* `block/patterns` is excluded by default because pattern files are read as content, not executed by the autoloader.
* Symlinked directories are not followed.
* Cached paths are accepted only when they still resolve to readable PHP files inside the filtered include root.
* Add relative file or directory paths to `porter_wp_inc_filepath_exclusions` to exclude them. An excluded directory also excludes its descendants.
* Change the root with `porter_wp_inc_filepath`, and alter priority names with `porter_wp_inc_load_first_filepaths`.

The discovered files and directories are stored in `porter_inc_files`, `porter_inc_directories` and `porter_inc_files_version`, and those entries are reused only in production. The signature includes the active theme, include root, `porter/inc/config.json`, visited directories and discovered files. Theme switches and normal file or directory changes therefore invalidate stale entries without relying only on a manually bumped version.
