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 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:XAMPPhtdocswordpresswp-contentthemesphotographyabout.php:2
Stack trace: #0 {main} thrown in
D:XAMPPhtdocswordpresswp-contentthemesphotographyabout.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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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.”

Method 2

get_header() is part of wordpress core.

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x