WordPress的列表中的所有帖子(节选)php循环
问题描述:
我正在创建一个WordPress模板,我现在需要一些代码,创建一个循环来显示所有帖子,但不是完整的帖子,只是摘录。WordPress的列表中的所有帖子(节选)php循环
任何人都可以帮忙吗?
答
使用此代码来生成摘录进入循环:
<?php
if(have_posts())
{
while(have_posts())
{
the_post();
the_excerpt();
}
}
?>
以上只产生帖子的摘录。如果您需要额外的选项,如帖子标题,日期,作者等,您必须阅读WordPress代码。 http://codex.wordpress.org/Main_Page
您可以通过以下markratledge给出的链接阅读更多。举例 - - 你需要知道
答
一切都在这里:http://codex.wordpress.org/The_Loop
最基本的循环是
<?php
if (have_posts()) {
while (have_posts()) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
,并要使用的the_excerpt()
代替the_content()
见http://codex.wordpress.org/Function_Reference/the_excerpt
我能有循环代码呢? – Satch3000
给我一秒钟 –
这很奇怪......我有3个帖子,只有1个正在上市,他们都已发布:o/ – Satch3000