自定义php(NON-CORE WORDPRESS FILE) 引用 wordpress

在文件头头添加下面代码,实现此页面可以调用wordpress的内置方法

<?php

$parse_uri = explode ( 'wp-content', $_SERVER ['SCRIPT_FILENAME'] );

$parse_uri [0] = ($_SERVER ['SCRIPT_FILENAME'] == $parse_uri [0]) ? substr ( $parse_uri [0], 0, strlen ( $parse_uri [0] ) - strlen ( basename ( $_SERVER ['PHP_SELF'] ) ) ) : $parse_uri [0];

require_once ($parse_uri [0] . 'wp-load.php');

?>

 

你可能感兴趣的:(wordpress)