Load Minimum of WordPress

A small contribution for all those using WordPress as a backend, framework or something similar. The applications, especially in the B2B sector, becoming more and more, as do the questions.

So far, I’ve always liked to recommended BackPress. But even a well-maintained standard is feasible, with all its advantages in the context of the philosophy of updates. WordPress reduces initializing to a minimum, if the constant SHORTINIT is set.

The wp-settings.php of WordPress is the key.

// Stop most of WordPress from being loaded if we just want the basics.
if ( SHORTINIT )
	return false;

Thus, the loading process is much slimmer and files that are loaded later, must be integrated via a Plugin or Theme functions. The ability is worth it and not infrequently, the part of WordPress in some projects is so small compared to your own developments, that this is worth to do.

Activating in wp-config.php via define( 'SHORTINIT', TRUE ); is done quickly and you can start the test, but note: the globals $wp, $wp_query, $wp_the_query was set as NULL.


Posted

in

by

Comments

12 responses to “Load Minimum of WordPress”

  1. Bjorn van der Neut Avatar

    If I add this I get the next error:

    Fatal error: Call to a member function main() on a non-object in /var/www/vhosts/ttweesp.nl/httpdocs/wp-includes/functions.php on line 1570

    What am i doing wrong?

  2. Frank Avatar

    @Bjorn: clean install? WP set this constant on a Multisite install also to.

  3. Simon Avatar
    Simon

    define(‘SHORTINIT’, true); seems to set the globals $wp, $wp_query, $wp_the_query as null and this causes the error that Bjorn gets (I also get the same error).

    Seeing if there is a way around this. Otherwise it seems setting it in wp-config.php is not the best idea.

    FYI – this is on a clean install or wp 3.3.1

  4. Frank Avatar

    @Simon: i think you must set the constant in a plugin or theme, there is the biggest part to use WP as Framework. But to check, how and what works with this smaller WP is the config the right part. Thanks for your helpfull reply!

  5. […] A small contribution for all those using WordPress as a backend, framework or something similar. The applications, especially in the B2B sector, becoming more and more, as do the questions. So far, I’ve always liked to recommended …More By Frank […]

  6. David Wood fin Avatar

    Hi,
    Thank you for your nice article. It will help me.
    Thanks

  7. Cristian Avatar
    Cristian

    Great as always guys, I was looking for something like this!

    Please, can you give me a hint on how to start after enabling the SHORTINIT?
    I mean, I imagine that I’ve to include a WP “main class” in my custom theme or in a plugin… could you show a short example?

    Huge thanks in advance!

  8. […] Load Minimum of WordPress – WP Engineer […]

  9. nicolas Avatar

    thank you very much for sharing this mini tutorial, I’ve been looking for it for hours and finally I found this, thanks really

  10. Mahabub Avatar

    nice tutorial thanks for share.

  11. Bharat Chowdary Avatar

    Thanks for this tip

  12. Gytis Avatar

    Interesting find, thanks for sharing. I was looking for that too! 🙂