我正在尝试让Wordpress之外的一个页面使用is_user_logged_in函数来确定他们是否可以查看某些数据。我已经登录了,并且Wordpress文件的路径是正确的。有人知道为什么我看不到数据吗?
<?php
error_reporting(E_ALL);
include('../blog/wp-load.php');
include('../blog/wp-blog-header.php');
if(is_user_logged_in()) {
//Do Something
} else {
echo 'Not logged in';
}
?>发布于 2016-04-03 15:46:28
我使用了require而不是include,现在你的代码已经很完美了。
<?php
error_reporting(E_ALL);
require(dirname(__FILE__) . '/wp-load.php' );
// include('/wp-blog-header.php');
if(is_user_logged_in()) {
//Do Something
echo "LoggedIN";
} else {
echo 'Not logged in';
}
?>https://stackoverflow.com/questions/10625257
复制相似问题