Switch the theme
wp_activate_themeSwitch the active theme to an installed theme (wp_install_theme installs one), named by its directory as wp_list_themes lists it (e.g. "twentytwentyfour", a child theme, or "collection/theme" for a theme inside a collection). Refuses, with the reason, a theme that is broken (a child without its parent), that the network does not allow on this site, or whose PHP/WordPress requirement this site does not meet. Records an undo point that switches back to the previous theme; the token is returned in "undo" (null when no snapshot could be taken). A theme taken back after a failed check is replaced by the previous one again. Activating is checked like an update: test requests check the home page, this MCP endpoint, wp-admin/admin-post.php and the dashboard before and after, logged in as this connection's account (where a security plugin refuses that login, the dashboard is left out and the answer says so). Where a target then shows a new fatal error, stops answering, or this MCP endpoint loses its own answer, the activation is taken back in the same call; the answer, an error, names the error with file and line, and the files stay as they are, so a corrected version can be activated again. Code has to let WordPress finish every request: code that ends the answer itself (fastcgi_finish_request(), or exit in the shutdown action) is taken back too, since the test cannot tell it from a broken one, and background work belongs in WP-Cron. A fatal error that was there before keeps the activation with a warning; a site that cannot reach itself is activated without a test, with the warning "not checked". Where code on every request filters the active plugins or the theme, so the site does not load what WordPress lists as active, the answer says so and the list stays as it was. One activation, update or deploy into running code runs at a time; a second is refused and changes nothing. Not checked: other wp-admin screens, cron, AJAX, code that runs only on some pages or for other users; what an activation routine writes to the database stays. Forwarded by AlphaBridge Connect to the one site this connection reaches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| theme | Yes | Theme folder (stylesheet) as wp_list_themes lists it in slug, e.g. "twentytwentyfour" or "collection/theme"; a child theme is named by its own folder, not its parent's. |