theme development - get_header() on new page fatal error

I'm building theme and using this link in navigation bar to about.php page.<li><a href="<?php ech

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\

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742275223a4413459.html

相关推荐

  • theme development - get_header() on new page fatal error

    I'm building theme and using this link in navigation bar to about.php page.<li><a href="<?php ech

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信