对于我的生命,我无法让这个工作(WP Codex的默认示例)。我用这段代码创建了一个php文件,并将其放在我的主题文件夹中,当我在web上访问该文件时,我得到一个空白页面,没有-我错过了什么,我必须把这个放在其他地方吗?如有任何帮助,不胜感激。
<?php
$email = 'myemail@example.com';
$exists = email_exists($email);
if ( $exists )
echo "That E-mail is registered to user number " . $exists;
else
echo "That E-mail doesn't belong to any registered users on this site";
?>
简单的回答,如果这是模板页面,那么使用以下命令:
<?php
$email = 'myemail@example.com';
$exists = email_exists($email);
if ( $exists )
echo "That E-mail is registered to user number ";
else
echo "That E-mail doesn't belong to any registered users on this site";
?>
和确保你有正确的开始和结束PHP标签。
但是如果不是来自模板页,那么使用这个:
<?php
require_once("../../../../wp-load.php"); //ADD THIS
$email = 'myemail@example.com';
$exists = email_exists($email);
if ( $exists )
echo "That E-mail is registered to user number ";
else
echo "That E-mail doesn't belong to any registered users on this site";
?>
添加或删除…/在require_once("../../../../wp-load.php")根据页面位置。这肯定对你有帮助。
尝试在文件中添加wp-load.php 正确路径
<?php
require_once("../../../wp-load.php"); //ADD THIS
$email = 'myemail@example.com';
$exists = email_exists($email);
if ( $exists )
echo "That E-mail is registered to user number " . $exists;
else
echo "That E-mail doesn't belong to any registered users on this site";
?>