我在我自己的網頁上使用The Loop來獲取WP的最後三個帖子。從wordpress文章中獲取有限的文本摘錄?
<?php
$args = array('numberposts' => 3);
$myposts = get_posts($args);
foreach($myposts as $post) : setup_postdata($post); ?>
<!-- DATE -->
<div class="date">
<?php the_time('m F Y');?>
</div>
<!-- TITLE -->
<div class="title">
<?php the_title(); ?>
</div>
<!-- SNIPPET -->
<div class="content">
<?php the_excerpt(); ?>
</div>
<?php endforeach; ?>
一切工作正常 - 除了the_excerpt()
。我需要大約15-20個來自帖子的純文本作爲預覽顯示。我如何去做這件事?
謝謝:)
很抱歉,這是抓住人物沒有的話我不是考慮清楚,如果你想的話這裏是如何做到這一點[這裏]功能(http://www.nutt.net/2004/12/29/php-a-function-to-return-the-first-n-words-from-a-string/) – Tianbo84 2011-03-15 07:18:42