我在wordpress中创建主题,我遇到了空白的索引页错误。
I think that the problem is in closing html and body tags but I am not sure.
`<!--Header.php file-->
<!DOCTYPE html>
<html <?php language_attributes();?>>
<head>
<meta charset="<?php blog_info('charset');?>">
<meta name="viewport" content="width=device-width">
<title><?php blog_info('name');?></title>
<?php wp_head();?>
</head>
<body <?php body_class();?>>
<div class="container">
<header class="site-header">
<h1><a href"<?php echo home_url();?>"><?php bloginfo('name');?></a></h1>
<h5><?php bloginfo('description');?></h5>
</header>`
`<!--Footer.php file-->
<footer class="site-footer">
<p><?php bloginfo('name');?> - © <?php echo date('Y')?></p>
</footer>
<?php wp_head();?>
</div> <!-- closing div container -->
</body>
</html>`
`
<!--Index.php file-->
<h1>Hello world!</h1>
<?php
get_header();
if (have_posts()):
while (have_posts()) : the_post();?>
<article class="post">
<h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
<?php the_content();?>
</article>
<?php endwhile;
else :
echo '<p>No content found</p>';
endif;
get_footer();
?>`
In my webpage only the Hello world! is showing.
我尝试删除header.php文件和footer.php文件中的所有内容,然后突然它起作用,但是当我在这些文件中添加内容时,我有空白页错误。谁能为我提供解决方案?会很感激。 &LT; 3
答案 0 :(得分:1)
我找到了解决方案。 我写了blog_info而不是bloginfo。傻傻的我!
答案 1 :(得分:0)
为什么你在footer.php中的footer.php用户wp_footer()函数中使用wp_head()函数。所有其他似乎都很好。
如果仍然没有解决问题。尝试逐个删除所有三个文件中的代码并检查导致问题的文件,然后逐行删除代码中的函数以检查导致问题的函数。