如何在 wordpress 主题中创建单个帖子页面? [英] How to create a single post page in wordpress theme?

查看:41
本文介绍了如何在 wordpress 主题中创建单个帖子页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 wordpress 主题的新手.我通过创建 index.php 和 style.css 创建了一个 wordpress 主题.这个主题实际上是一个博客主题.所以,我设计了 index.php 中的所有部分,这是我的首页,我编写了 php 代码来自动显示来自 wordpress 的博客文章.它工作正常.

I am new to wordpress theme. I have created a wordpress theme by creating index.php and style.css. This theme is actually a blog theme. So, i have designed all the section in index.php and that is my front page and i have write the php code to display the blog post from the wordpress automaticaly. It works fine.

我的问题是,当我点击博客文章的标题时,它会转到下一个页面,该页面指示 mysitenamedomain/post-id,而我在该页面上似乎没有任何内容.我是否要创建一个 single.php 页面来在该页面上显示标题、内容等?

My question is, when i click on the title of the blog post it goes to the next page which indicates mysitenamedomain/post-id and i seems nothing on that page. whether i want to create a single.php page to display the title, content etc on that page?

推荐答案

在 single.php 中你必须使用 loop

In single.php you have to use loop

这里是文档:Codex尝试:(在 single.php 中):

Here is documentation: Codex Try: (in single.php):

<?php while ( have_posts() ) : the_post(); ?>
<h3><?php the_category('&nbsp;&rsaquo;&nbsp;'); echo "&nbsp;&rsaquo;&nbsp;"; the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; // end of the loop. ?>

当然,你必须设计它.

这篇关于如何在 wordpress 主题中创建单个帖子页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆