2

I am using this code to go to a page. In my directory there is theme folder 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> 

But going to page url wp-content/themes/live/ch/bn1.php shows this message

Fatal error: Call to undefined function get_header() in C:\wamp\www\blog\wp-content\themes\live stream\ch\bn1.php on line 1

My theme directory is

www/blog/wp-content/themes/live stream 

My page to go to the directory is

www/blog/wp-content/themes/live stream/ch/bn1.php 
1
  • Welcome to Stack Overflow. I have fixed English issues with your post. I have also marked your urls. Note that I marked the error message with a leading >. Commented Jan 3, 2016 at 13:41

1 Answer 1

6

You are calling that file, but you are not loading up the rest of WordPress. Therefore get_header() doesn't exist.

WordPress does not work the way you are trying to use it here. You should create a page template, then create a page in the WordPress admin with this template and then link to the page URL which will be shown in the page editing screen. You can't just link straight to the template.

To create page templates the WordPress way try reading https://developer.wordpress.org/themes/template-files-section/page-template-files/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.