Read a theme file
wp_read_theme_fileRead the contents of a file inside an installed theme (defaults to the active theme). A theme is named by its folder as wp_list_themes lists it; a path outside the theme directories is refused. Returns file, content (the raw text), bytes, file_size and offset; files over 2 MB are read in slices (offset/length). A missing file or theme is an error; plugin and uploads files have their own readers (wp_read_plugin_file, wp_read_upload_file). Requires edit_themes; runs only with the site's write access on. Forwarded by AlphaBridge Connect to the one site this connection reaches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | Path relative to the theme folder, e.g. "functions.php" or "parts/header.html", as wp_list_theme_files lists it; a path leaving the theme is refused. | |
| theme | No | Installed theme, by its folder name as wp_list_themes lists it ("collection/theme" for a theme inside a collection). A theme WordPress counts as broken (for example a folder without style.css in wp-content/themes) can be named too, although wp_list_themes leaves it out. Default: the active theme. | |
| length | No | Number of bytes to read, at most 2 MB per call. Default: up to 2 MB from offset when offset is above 0; otherwise the whole file, which a file over 2 MB is refused for (offset 0 needs a length to read a slice). | |
| offset | No | Byte offset to start reading from. Default 0. |