未捕获的错误:调用未定义的函数have_post()

Jes*_*m17 2 wordpress

我试图看看我的WordPress主题,但收到此错误:

致命错误:未捕获错误:调用C:\ xampp \ htdocs \ wordpress \ wp-content \ themes \ ChachoTheme \ index.php:6中未定义的功能have_post()堆栈跟踪:#0 C:\ xampp \ htdocs \ wordpress \ wp-includes \ template-loader.php(74):include()#1 C:\ xampp \ htdocs \ wordpress \ wp-blog-header.php(19):require_once('C:\ xampp \ htdocs ... ')#2 C:\ xampp \ htdocs \ wordpress \ index.php(17):require('C:\ xampp \ htdocs ...')#3 {main}抛出C:\ xampp \ htdocs \ wordpress \第6行的wp-content \ themes \ ChachoTheme \ index.php

index.php:

<?php if (have_post() ):?>
  <?php while(have_post()):the_post(); ?>

<div id="post">

  <h2><a href="<?php the_permalink(); ?>"></a><?php the_title(); ?></h2>
  <div class="byline">Escrito por <?php the_autor_posts_link(); ?>
    el <a href="<?php the_permalink(); ?>"><?php the_time('l F d, Y'); ?></a>
  </div>
  <?php the_content('Read More..'); ?>
<?php endwhile; ?>
<?php else: ?>
  <p>No posts were found. Sorry!")</p>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

我该如何解决?

ash*_*ghe 5

尝试have_posts()代替您的have_post()。

同时更改the_autor_posts_link()为the_author_posts_link():

<?php if (have_posts() ):?>
  <?php while(have_posts()):the_post(); ?>

<div id="post">

  <h2><a href="<?php the_permalink(); ?>"></a><?php the_title(); ?></h2>
  <div class="byline">Escrito por <?php the_author_posts_link(); ?>
    el <a href="<?php the_permalink(); ?>"><?php the_time('l F d, Y'); ?></a>
  </div>
  <?php the_content('Read More..'); ?>
<?php endwhile; ?>
<?php else: ?>
  <p>No posts were found. Sorry!")</p>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)