我想看看我的WordPress主题,我收到了这个错误:
致命错误:未捕获错误:在C:\ xampp \ htdocs \ wordpress \ wp-content \ themes \ ChachoTheme \ index.php中调用未定义函数have_post():6堆栈跟踪:#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 {6}在第6行的C:\ xampp \ htdocs \ wordpress \ 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; ?>
我该如何解决?
答案 0 :(得分:3)
尝试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; ?>
答案 1 :(得分:1)
像这样编写代码:
<?php
if ( have_posts() ) {
while ( have_posts() ) {
?>
<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..'); ?>
</div>
<?php
}
} else { ?>
<p>No posts were found. Sorry!")</p>
<?php }
?>