最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - get_header() on new page fatal error

programmeradmin3浏览0评论

I'm building theme and using this link in navigation bar to about.php page.

<li><a href="<?php echo get_template_directory_uri(); ?>/about.php">אודות</a></li>

Now I can't understand why but when I enter about.php I get the following error:

Fatal error: Uncaught Error: Call to undefined function get_header() in D:\XAMPP\htdocs\wordpress\wp-content\themes\photography\about.php:2 Stack trace: #0 {main} thrown in D:\XAMPP\htdocs\wordpress\wp-content\themes\photography\about.php on line 2

About.php page

<?php get_header(); ?>

<?php get_footer(); ?>

I'm not sure if I need to define something in my functions.php file.

How can I load properly get_header(); function in about.php?

I'm building theme and using this link in navigation bar to about.php page.

<li><a href="<?php echo get_template_directory_uri(); ?>/about.php">אודות</a></li>

Now I can't understand why but when I enter about.php I get the following error:

Fatal error: Uncaught Error: Call to undefined function get_header() in D:\XAMPP\htdocs\wordpress\wp-content\themes\photography\about.php:2 Stack trace: #0 {main} thrown in D:\XAMPP\htdocs\wordpress\wp-content\themes\photography\about.php on line 2

About.php page

<?php get_header(); ?>

<?php get_footer(); ?>

I'm not sure if I need to define something in my functions.php file.

How can I load properly get_header(); function in about.php?

Share Improve this question asked Jul 10, 2020 at 13:38 Yotam DahanYotam Dahan 1096 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 1

Look into the theme template hierarchy. There is no "about.php" file and you should not link to any of the theme (PHP) files directly. Instead, you would create a theme file such as "page-about.php" and create its content in wp-admin as a Page with the slug "about," and WordPress will process that Editor content within the PHP file to create the final visible page. If you have pretty permalinks enabled you will want to link to "/about/" instead of the theme file, but because you have named the PHP file "page-about," WP will apply it to a Page with the slug "about."

get_header() is part of wordpress core.

Seems your wordpress files damaged or installed incorrect. Try to reinstall it. Probably you should move D:\XAMPP\htdocs\wordpress into D:\XAMPP\htdocs\

发布评论

评论列表(0)

  1. 暂无评论