对于我的生活,我无法使其工作(WP Codex的默认示例)。我创建了一个带有此代码的php文件并将其放在我的主题文件夹中,当我在网上访问该文件时,我得到一个空白页面,虚无... - 我错过了什么,我是否必须把它放在其他地方?非常感谢任何帮助。
<?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";
?>
答案 0 :(得分:1)
简单的回答, 如果那是模板页面,请使用:
<?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标记。
但如果是来自tempalte页面以外的其他页面,请使用:
<?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”)中添加或删除../。 这肯定会对你有帮助。
答案 1 :(得分:0)
尝试使用 正确路径在您的文件中添加 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";
?>