I'm creating a custom WordPress theme, more specifically the index.php file. When I navigate to my website main page, the header is displayed correctly, but occasionally errors show in the server log:
PHP Fatal error: Uncaught Error: Call to undefined function get_header() in D:\home\site\wwwroot\wp-content\themes\OryTheme\index.php:1
Stack trace:
#0 {main}
thrown in D:\home\site\wwwroot\wp-content\themes\OryTheme\index.php on line 1
I don't know why it gives an error if it displays the header. Also, if I remove <?php get_header(); ?>, the header won't get displayed. Can I ignore these errors?
index.php
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<h1><?php the_title(); ?></h1>
<h4>Posted on <?php the_time('F jS, Y') ?></h4>
<p><?php the_content(__('(more...)')); ?></p>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>