[wp-hackers] Bootstrapping WordPress

Tom Barrett tcbarrett at gmail.com
Tue Oct 4 15:37:20 UTC 2011

On 4 October 2011 16:19, Dagan Henderson <Dagan.Henderson at epyllion.com>wrote:

> I'm working on a process that requires a cron job and would prefer to
> execute the PHP script directly instead of using cURL to execute the code
> via the Web server. In the past, I've bootstrapped WordPress, through trial
> and error and Googling like this:
> require('<path-to>/wp-config.php');
> $wp->init();
> $wp->parse_request();
> $wp->query_posts();
> $wp->register_globals();
> Is there a preferred method for bootstrapping, or is this as good as any?
> Cheers!

I was shown this method (assuming PHP script is in the docroot):

// Turn off errors as we're sort of outside wordpress
// and the browser and that can cause warnings
define('WP_DEBUG', false);

// Require the standard WordPress header


http://www.tcbarrett.com | http://gplus.to/tcbarrett |

More information about the wp-hackers mailing list