Include Wordpress Core into own Scripts

前端 未结 3 1941
深忆病人
深忆病人 2020-12-08 08:33

I\'m trying to \"Import\" the Wordpress core into an own script to use the functionality such as wp_query etc. I\'ve created an script in a subdirectory (own framework) and

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 09:26

    The easiest way to access everything wordpress has programmed in is to use the following:

    require_once('/../../../wp-blog-header.php'); // Use actual root path to wp-blog-header.php
    header("HTTP/1.0 200 OK");
    

    Using the above code you'll get all functions you would normally get using a template with in WordPress. I've tried all the other methods listed above and this one is by far the best.

提交回复
热议问题