18

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?

4
  • 1
    I think it should show blank page if there is no theme in theme folder.
    – Robert hue
    Sep 5, 2014 at 9:07
  • 3
    As far as understand you need to have a theme for Worpdress to work. What are you trying to achieve ie. why are you asking this question?
    – stemie
    Sep 5, 2014 at 9:24
  • 3
    No, you don't need a theme for WordPress to work. Theme is mostly for displaying content and if it's not your requirement (may be for a special project) then WordPres will work just fine that way except wp-cron. For that you can use external cron. Also the answer below really sums it up.
    – Robert hue
    Sep 5, 2014 at 10:03
  • Do what I did, and use the concept described here, then build your own.
    – eyoung100
    Sep 5, 2014 at 19:10

2 Answers 2

29

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" ;-)

8
  • 2
    Actually it's perfect answer.
    – Robert hue
    Sep 5, 2014 at 9:58
  • 1
    Nice song with and a even nicer implementation. John Lennon would be proud. +1 Sep 5, 2014 at 10:04
  • 2
    Definitely an upvote for the imagine cite :) too bad I can't give you another one for the answer. Sep 5, 2014 at 10:04
  • 1
    I totally agree with @ialocin Can unfortunately only give one upvote per answer. Sep 5, 2014 at 10:09
  • 1
    I just stumpled up on the missing exit in the template redirect hook, a Friday coincident ;-) @PieterGoosen
    – birgire
    Feb 13, 2015 at 15:00
13

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.

  • admin side has its own (and numerous) ones, such as wp-admin/index.php.
  • front side almost universally goes through index.php in the very root, but it's usually "hidden" by pretty permalinks

If 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.