How to create a single post page in wordpress them

2019-07-04 21:55发布

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?

2条回答
神经病院院长
2楼-- · 2019-07-04 22:06

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('&nbsp;&rsaquo;&nbsp;'); echo "&nbsp;&rsaquo;&nbsp;"; the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; // end of the loop. ?>

Of course you have to style it.

查看更多
3楼-- · 2019-07-04 22:09

login admin panel and create a new post here by clicking the "POST" menu of dashboard, put the post title and post content here and then save it . after that check single page on website it will display the title , content etc

查看更多
登录 后发表回答