我是一名新的WordPress开发人员,最近我在多个网站上遇到了一些问题include_once
和require_once
用于PHP文件。如果我包括(get_theme_directory_uri() . \'subdir/file\')
指定的文件被包括在内(或是必需的,这会导致致命错误),但如果在“文件”中调用任何WordPress函数,我会得到类似的结果:
\'Call to undefined function add_action()
in/full/path/to/file\'。
我找到的明显解决方案是:
include(dirname(__FILE__) . "/subdir/filename");
这是对的还是我错过了在某处包含文件的“WordPress方式”?