How to create a single post page in wordpress theme?
17,500
In single.php you have to use loop
Here is documentation: Codex
Try: (in 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. ?>
Of course you have to style it.
Related videos on Youtube
Author by
user2644743
Updated on June 28, 2022Comments
-
user2644743 almost 2 years
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.
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?
-
Raptor almost 8 yearsThat's incorrect. In single page, there is only 1 post. No
while
loop is required.