在wordpress的子主题中引用文件如何写?

在wordpress的子主题的functions.php文件中用下面的代码引用一个php文件,结果前台后台都出现了500错误。
请教大神哪里写的不对?

require_once get_stylesheet_directory_uri() . '/custom/login.php';

在子主题中不就是应该用get_stylesheet_directory_uri()获取当前子主题的路径么?
谢谢

阅读 4.1k
2 个回答

我一般这么写:

require_once(TEMPLATEPATH . '/custom/login.php');

真是不好意思了,找到问题出在哪里了,是我自己用错了钩子了,应该用get_stylesheet_directory()

require_once get_stylesheet_directory() . '/custom/login.php';
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进