内容在我的single.php中不可见

问题描述 投票:0回答:1

我的页面帖子没有显示在我的single.php文件中。这是我的页面的链接:http://list.thorsteinnhelgason.is/index.php/blog/

这是我使用的代码:

<div class="container">
 <div id="content">
   <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <h2><?php the_title(); ?></h2>
      <?php the_content(); ?>
    <?php 
      endwhile; 
      endif; 
     ?>
 </div>
</div>
php wordpress post
1个回答
0
投票

single.php将不是您想要的文件。 single.php(用于帖子)或singualr.php(帖子或页面)用于显示单个帖子,而不是帖子列表。

您链接到的页面,基于名称,是基于wordpress模板的帖子(或循环)列表,heirarchy将使用index.php,home.php,front-page.php https://developer.wordpress.org/themes/basics/template-hierarchy/

评估它实际加载的模板的最简单方法是编辑header.php并调整<body>的行

<body <?php body_class() ?> >

这样它就会告诉你它正在尝试用什么模板项来显示你所在的页面,在页面的类中。

© www.soinside.com 2019 - 2024. All rights reserved.