Does WordPress work without a theme? If so, then how does it work? Please explain in brief.
If WordPress is displaying content without a theme, what controls the output?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityDoes WordPress work without a theme? If so, then how does it work? Please explain in brief.
If WordPress is displaying content without a theme, what controls the output?
I think there's a song for that:
"Imagine there's no theme. It's easy if you try. No hell below us. Above us only sky ..." ;-)
So in that imaginary dream:
you can still fetch the RSS feeds from your site:
example.com/feed/
you can still login to your backend:
example.com/wp-login.php
you can still access the backend and work there (almost) as usual:
example.com/wp-admin/
scheduling posts will not work so you will get the Missed schedule message.
wp-cron
will not be reliable.
you can still access /wp-admin/admin-ajax.php
you can use the template_redirect
and tempate_include
hooks to control the output. Try for example this tiny plugin:
<?php
/** Plugin Name: No-Theme-Day **/
add_action( 'template_redirect',
function()
{
wp_die( __( "Jibby! It's the No-Theme-Day today!" ) );
}
);
...
ps: Forgive my Friday answer - "But I'm not the only one" ;-)
Since using WordPress without theme is quite rare the technicalities of it don't get much attention.
First you have to understand there are multiple "endpoints" in WordPress core dealing with requests.
wp-admin/index.php
.index.php
in the very root, but it's usually "hidden" by pretty permalinksIf you take a look at the latter file it has following line:
define('WP_USE_THEMES', true);
So typically WordPress expects front end to always have a theme and configures runtime environment accordingly. This constant doesn't control that much, only if theme templates are going to be loaded in template-loader.php
.
Note that it doesn't prevent parent/child themes (if present) to be loaded during core boot process.
So by default WordPress expects at least one theme to be present, enabled, and have templates to be used for purposes of front end display.
This is, however, just a matter of defaults and can be completely configured away. In such case WordPress will continue to fully function on admin side, while on front end side all requests that rely on theme template will cease to display anything.