How to create a single post page in wordpress theme?

两盒软妹~` 提交于 2019-12-10 18:43:44

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/18010004/how-to-create-a-single-post-page-in-wordpress-theme

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!