Search⌘ K

Single Post and Page Template

Explore how to create and customize single post and page templates in WordPress by using the single.php and page.php theme files. Learn to modify the WordPress Loop to display content appropriately on individual post and page views, enhancing your theme's functionality.

Template files

The index.php file powers the homepage. The code in the previous lesson lists the 10 most recent blog posts. If we visit the page of a single blog post, we need it to display the content slightly differently. Specifically, we do not need the title to be a link anymore because we are already on the detail screen and it makes no reason to click the title again. Also there is no need to display the horizontal rule for separation as there is just one post on this page.

Single post
Single post

The single.php file

In a theme, we have different files that display different pages. The file named single.php is responsible for displaying an individual post.

Create a file named single.php inside the ...