Skip to main content

benecaster_get_installed_templates()

Template Free
benecaster_get_installed_templates(): array|WP_Error

Returns every design template the site can activate, active or not — the two built-ins shipped with the plugin first, then anything installed from a zip. Each row carries a built_in flag telling the two apart.

Chiefly used as an “only install once” guard: an add-on that bundles a template checks whether its slug is already present before unpacking the zip.

Return Value

Type: array|WP_Error

A list of manifest arrays — each carrying name, slug, version, requires, author, author_url, description, screenshot, install_path and built_in — or a WP_Error with code benecaster_template_lookup_failed.

Example

// Only unpack the bundled zip once, rather than on every boot.
foreach ( benecaster_get_installed_templates() as $template ) {
    if ( 'my-addon-template' === $template['slug'] ) {
        return; // already installed
    }
}

Notes

This is never empty on a working install, because the two built-ins are always present. An empty array means the lookup found nothing at all, which should not happen on a healthy site.

A built_in row cannot be uninstalled, and its install_path and screenshot are empty strings. It can be activated like any other.

Each entry is an array, not a TemplateManifest. Use $template['slug'], not $template->slug. The whole published template surface answers in one shape, so the same access form is correct everywhere.

To ask "is a template in force right now?" use benecaster_get_active_template() instead. This function answers what is available, not what is selected.

Need this built rather than just documented? See our services →