R
R
Rad1us2015-11-22 14:22:59
WordPress
Rad1us, 2015-11-22 14:22:59

Error - "Call to undefined function get_header()" in Wordpress. How to win?

Made a blog template. I started to transfer it to wordpress (before that, I had never worked with any CMS). I made index.php, header.php, sidebar.php, footer.php and in the right places in index.php I registered the function of calling header, footer and sidebar. Plus, I made a cycle for displaying articles on the main page. In general, I reached the stage of creating single.php, in theory it should be called when I click on the link at the bottom of the post from the main page. In general, I created a file, just like in index.php, I made a call to the unchanged parts of the template - header, sidebar and footer, but now when I click on my link, which should call single.php, an error occurs:
Fatal error: Call to undefined function get_header() in X:\home\cite1.ru\www\wordpress\wp-content\themes\mytheme\single.php on line 1
If you remove the first line that he swears at, then he will start swearing at the next PHP functions and so on. At the same time, if you remove all PHP code, then the page is displayed, but without styles (which is understandable).
How to overcome this error and what am I doing wrong?
Here is my single.php

<?php get_header(); ?>
      <div class="page-wrapper">
        <div class="left">
        
        <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
        
          <div class="post">
            <div class="date"><?php the_time('j M Y');?></div>	
            <h1 class="title"><a href="#"><?php the_title();?></a></h1>	
            <div class="tag"><a href="#"><a></div>
            <div class="content">
              <?php the_content();?>
            </div>	
          </div>
          
        <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
        <?php else : ?>
        <?php endif; ?>		
        
            </div>
<?php get_sidebar(); ?>				
        <div class="clearfix">
        </div>
      </div>
<?php get_footer(); ?>

Here is the header.php code
<!DOCTYPE html>
  <html>
    <head><link href="\wordpress\wp-content\themes\mytheme\style\style.css" rel="stylesheet">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
      <div class="header-wrapper">
        <div class="header">
          <div class="logo-wrapper">
            <a href="\wordpress\wp-content\themes\mytheme\index.php">Блог</a>
          </div>
          <div class="menu-wrapper">
            <ul class="menu">
              <li><a href="#">Карта сайта</a></li>
              <li><a href="#">Полезное</a></li>
              <li><a href="#">Контакты</a></li>
            </ul>
          </div>
        </div>
      </div>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rad1us, 2015-11-23
@rad1us

Ufff, I finally figured it out, the problem was this: a link of the form

<a href="\wordpress\wp-content\themes\mytheme\single.php">читать далее</a>
Does not work.
It should have been written like this:
<a href="<?php the_permalink() ?>">читать далее</a>
This way wp understands that it needs to load the post currently in the loop into single.php and display it.
Everything just turned out. Hope it helps someone else.

E
eskrano, 2015-11-22
@eskrano

There may be something with the theme of the cap, or something that has not been included. Do not suffer garbage at all, hammer on this one.

M
Mr Crabbz, 2015-11-22
@Punkie

Put this topic in parallel: underscores.me
If it also does not work, then you have a problem with the WordPress distribution. Download fresh from the site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question