开发者

Wordpress list all posts (excerpt) php loop

开发者 https://www.devze.com 2023-04-11 10:21 出处:网络
I am creating a wordpress template and I now need some code that creates a loop to show all posts but not full posts, jus开发者_如何学运维t excerpts.

I am creating a wordpress template and I now need some code that creates a loop to show all posts but not full posts, jus开发者_如何学运维t excerpts.

Can anyone help please?


Use this code to generate the excerpt into the loop:

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

            the_excerpt();
        }
    }
?>

The above will generate only the excerpt of the posts. If you need extra options like post title, date, author and more you have to read the WordPress codex. http://codex.wordpress.org/Main_Page

You can read more by following the link given by markratledge below.


Everything you need to know - with examples - is here: http://codex.wordpress.org/The_Loop

The most basic loop is

<?php 
if ( have_posts() ) {
    while ( have_posts() ) {
        the_post(); 
        //
        // Post Content here
        //
    } // end while
} // end if
?>

and you want to use the_excerpt() instead of the_content() See http://codex.wordpress.org/Function_Reference/the_excerpt

0

精彩评论

暂无评论...
验证码 换一张
取 消