1
没有人知道使用wp_rss截断rss提要的最佳方法吗?我尝试了Google搜索,似乎无法找到任何东西。任何帮助,将不胜感激!如何截断wp_rss
这里是我的代码:
<?php
include_once(ABSPATH . WPINC . '/rss.php');
$feed = 'http://miletich2.blogspot.co.uk/feed/';
$rss = fetch_feed($feed);
?>
<div class="container">
<div class="right">
<div class="rss-container">
<div class="rss-heading">
<?php
$title = "Clashing With Life";
$description = 'This is a blog written by an autistic person for other autistic people about <br>some of the biggest issues in life, whether deplorable or marvelous.';
echo '<h3 class="text-center">' . $title . '</h3>';
echo '<p class="">' . $description . '</p>';
?>
</div>
<div class="text-center">
<?php
if (!is_wp_error($rss)) :
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
if ($rss_items):
echo "<ul>\n";
foreach ($rss_items as $item) :
//instead of a bunch of string concatenation or echoes, I prefer the terseness of printf
//(http://php.net/manual/en/function.printf.php)
printf('<div class=""><li><a href="%s">%s</a><p>%s</p><p>%s</p></li></div>',$item->get_permalink(),$item->get_title(),$item->get_date(get_option('date_format')),$item->get_description());
'<hr>';
endforeach;
echo "</ul>\n";
endif;
endif;
?>
</div>
</div>
</div>
</div>
你太棒了!谢谢! – avasssso