我是 wordpress 主题的新手。我通过创建 index.php 和 style.css 创建了一个 wordpress 主题。这个主题实际上是一个博客主题。所以,我已经设计了 index.php 中的所有部分,这是我的首页,我已经编写了 php 代码来自动显示来自 wordpress 的博客文章。它工作正常。
我的问题是,当我点击博客文章的标题时,它会转到显示 mysitenamedomain/post-id 的下一页,而我在该页面上似乎什么都没有。我是否要创建一个 single.php 页面来在该页面上显示标题、内容等?
最佳答案
在 single.php 中你必须使用 loop
这里是文档:Codex
试试:(在 single.php
中):
<?php while ( have_posts() ) : the_post(); ?>
<h3><?php the_category(' › '); echo " › "; the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; // end of the loop. ?>
当然,你必须设置它的样式。
关于wordpress - 如何在 wordpress 主题中创建单个帖子页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18010004/