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:wampwwwblogwp-contentthemeslive streamchbn1.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
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/