wordpress全局变量$wpdb初始化并声明为全局变量的方法


本文整理自网络,侵删。

首先从wordpress程序index.php入手:


代码如下:

define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

index.php加载了wp-blog-header.php文件,再打开看看:


代码如下:

if ( !isset($wp_did_header) ) {
$wp_did_header = true;
require_once( dirname(__FILE__) . '/wp-load.php' );
wp();
require_once( ABSPATH . WPINC . '/template-loader.php' );
}

再打开wp-load.php:


代码如下:

if ( file_exists( ABSPATH . 'wp-config.php') ) {

/** The config file resides in ABSPATH */
require_once( ABSPATH . 'wp-config.php' );

} elseif ( file_exists( dirname(ABSPATH) . '/wp-config.php' ) && ! file_exists( dirname(ABSPATH) . '/wp-settings.php' ) ) {

/** The config file resides one level above ABSPATH but is not part of another install */
require_once( dirname(ABSPATH) . '/wp-config.php' );

} else {
……
}

它加载了配置文件config.php,打开config.php看看:

阅读剩余部分

相关阅读 >>

mac osx下使用mamp安装配置php开发环境

wordpress特定文章对搜索引擎隐藏或只允许搜索引擎查看

wordpress修改某篇文章id(把id为148的改成147)的sql语句

完美实现wordpress禁止文章修订和自动保存的方法

wordpress中用于获取文章信息以及分类链接的函数用法

美国高性价比主机justhost的购买及站点搭建教程

探讨一下国外主流建站工具的优缺点

wordpress安装使用flowplayer简易指南

wordpress配置文件wp-config.php详解

wordpress在iis服务器上的伪静态设置方法(解决中文url无法访问问题)

更多相关阅读请进入《wordpress》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...