簡體   English   中英

WordPress列出所有帖子(摘錄)的PHP循環

[英]Wordpress list all posts (excerpt) php loop

我正在創建一個wordpress模板,現在需要一些代碼來創建一個循環以顯示所有帖子,但不顯示完整的帖子,僅顯示摘錄。

有人可以幫忙嗎?

使用以下代碼將摘錄生成到循環中:

<?php
    if(have_posts())
    {
        while(have_posts())
        {
            the_post();

            the_excerpt();
        }
    }
?>

上面只會生成帖子的摘錄。 如果您需要額外的選項,如帖子標題,日期,作者等,則必須閱讀WordPress Codex。 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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM