我在index.php的最后一行有一个错误,我不确定它可能是什么
您好,有人能帮我吗?我的PHP被成功编译时遇到了问题。它说这是最后一行,但我认为最后一行是正确的。我没有足够的经验知道它是否正确我在index.php的最后一行有一个错误,我不确定它可能是什么,php,wordpress,Php,Wordpress,您好,有人能帮我吗?我的PHP被成功编译时遇到了问题。它说这是最后一行,但我认为最后一行是正确的。我没有足够的经验知道它是否正确 <?php get_header(); ?> <?php if( have_posts() ) { ?> <?php while( have_posts() ) { ?> <?php the_post(); ?> <h2> <a href
<?php get_header(); ?>
<?php if( have_posts() ) { ?>
<?php while( have_posts() ) { ?>
<?php the_post(); ?>
<h2>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title() ?> </a>
</h2>
} else { ?>
<p>Sorry, No post matched</p>
<?php } ?>
<?php get_footer(); ?>
}还有{?>
对不起,没有匹配的帖子
首先,您没有关闭while循环。也没有打开php。您不能执行}其他操作{?>
<?php get_header(); ?>
<?php if(have_posts()) { ?>
<?php while(have_posts()) { ?>
<?php the_post(); ?>
<h2>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title() ?> </a>
</h2>
<?php } //while end
} else { ?>
<p>Sorry, No post matched</p>
<?php } ?>
<?php get_footer(); ?>
对不起,没有匹配的帖子
试试这段代码
<?php get_header(); ?>
<?php if( have_posts() ) { ?>
<?php while( have_posts() ) : the_post(); ?>
<h2>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title() ?></a>
</h2>
<?php endwhile; ?>
<?php } else { ?>
<p>Sorry, No post matched</p>
<?php } ?>
<?php get_footer(); ?>
对不起,没有匹配的帖子
您尚未关闭循环。请尝试以下操作:
<?php get_header(); ?>
<?php if(have_posts()) { ?>
<?php while(have_posts()) { ?>
<?php the_post(); ?>
<h2>
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title() ?> </a>
</h2>
<?php } // end while loop (here was you mistake) ?>
<?php } else { ?>
<p>Sorry, No post matched</p>
<?php } ?>
<?php get_footer(); ?>
对不起,没有匹配的帖子
您也可以发布错误吗?请关闭while循环。请阅读。在询问类似问题时逐字引用错误消息,而不是含糊其辞地告诉我们您“有”错误!