[wp-hackers] Access the wordpress menu from another CMS in a subdirectory
    Ryan McCue 
    lists at rotorised.com
       
    Sat Jul  7 03:20:08 UTC 2012
    
    
  
Dwain Maralack wrote:
> <?php
>        // no theme output
> define('WP_USE_THEMES', false);
>
> $_SERVER = array(
>     "HTTP_HOST" => "http://localhost:8888/akfam/",
>      "SERVER_NAME" => "http://localhost:8888/akfam/",
>      "REQUEST_URI" => "/",
>     "REQUEST_METHOD" => "GET"
> );
You shouldn't need to do any of this unless you have badly behaving plugins.
> // initializes  Wordpress
> require_once('/Users/miiweb1/Sites/akfam/wp-blog-header.php');
Use wp-load.php here instead of wp-blog-header.php
----
Here's what I use:
<?php
class MyClass {
	// ...
	public static function load_wp() {
		if (empty(self::$wp_path)) {
			throw new Exception('WordPress could not be loaded', 500);
		}
		global $wp_the_query, $wp_query, $wp_rewrite, $wp;
		define('DISABLE_WP_CRON', true);
		require_once(self::$wp_path . '/wp-load.php');
	}
The globals are required if loading through a function. There may be 
others as well depending on what plugins you have. (WP should really 
have that built in, rather than assuming it's in the global context.)
DISABLE_WP_CRON is for performance reasons; I don't want cron running on 
the site this lives on.
-- 
Ryan McCue
<http://ryanmccue.info/>
    
    
More information about the wp-hackers
mailing list