Fatal error: Call to undefined function get_header()
Fatal error: Call to undefined function get_header()
我正在使用此代码转到某个页面。在我的目录中
有主题文件夹ch.
<li>
<a href="<?php echo get_stylesheet_directory_uri(); ?>/ch/bn1.php">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/bn1.png">
</a>
</li>
但是转到页面 url wp-content/themes/live/ch/bn1.php 显示此消息
Fatal error: Call to undefined function get_header() in C:\wamp\www\blog\wp-content\themes\live stream\ch\bn1.php on line 1
我的主题目录是
www/blog/wp-content/themes/live stream
我要转到目录的页面是
www/blog/wp-content/themes/live stream/ch/bn1.php
您正在调用该文件,但您没有加载 WordPress 的其余部分。因此 get_header()
不存在。
WordPress 无法按照您在此处尝试使用的方式工作。您应该创建一个页面模板,然后使用此模板在 WordPress 管理中创建一个页面,然后 link 到页面 URL,该页面将显示在页面编辑屏幕中。您不能 link 直接使用模板。
要以 WordPress 方式创建页面模板,请尝试阅读 https://developer.wordpress.org/themes/template-files-section/page-template-files/
我正在使用此代码转到某个页面。在我的目录中 有主题文件夹ch.
<li>
<a href="<?php echo get_stylesheet_directory_uri(); ?>/ch/bn1.php">
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/bn1.png">
</a>
</li>
但是转到页面 url wp-content/themes/live/ch/bn1.php 显示此消息
Fatal error: Call to undefined function get_header() in C:\wamp\www\blog\wp-content\themes\live stream\ch\bn1.php on line 1
我的主题目录是
www/blog/wp-content/themes/live stream
我要转到目录的页面是
www/blog/wp-content/themes/live stream/ch/bn1.php
您正在调用该文件,但您没有加载 WordPress 的其余部分。因此 get_header()
不存在。
WordPress 无法按照您在此处尝试使用的方式工作。您应该创建一个页面模板,然后使用此模板在 WordPress 管理中创建一个页面,然后 link 到页面 URL,该页面将显示在页面编辑屏幕中。您不能 link 直接使用模板。
要以 WordPress 方式创建页面模板,请尝试阅读 https://developer.wordpress.org/themes/template-files-section/page-template-files/