是否可以在single.php中更改HTML?

是否可以在single.php中更改HTML?

问题描述:

I've got a series of images as posts, generated by the loop. As you can see here. Once you click on an image, it takes you to a single post page.

I need to alter the HTML on the single post page only. Is this possible?

我有一系列图像作为帖子,由循环生成。 您可以查看此处。 单击图像后,它会将您带到一个帖子页面。 p>

我只需要在单个帖子 strong>页面上更改HTML。 这可能吗? p> div>

Yes, you can.

Here's how WordPress finds which file to use when displaying a single post:

single-{post-type}.php > single.php > index.php

So, first WP will look in the theme for single-{post-type}.php. Which it will use for a specific type of post. If no such file exists then it will look for a single.php. Which WP will use for displaying all single posts. If no such files exists then it will fallback on your index.php file to display single posts.

So, either create a single-{post-type}.php or a single.php and add your modified HTML there.

In your theme files there should be a file named single-post.php. If you open this file with a text editing program you will be able to edit your single post layout.

BE AWARE When you edit this file, all of the pages using single-post.php will be changed as well.

Hope this helps.