Created
February 24, 2012 08:42
-
-
Save s-hiroshi/1899487 to your computer and use it in GitHub Desktop.
WordPress > get rss feed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>外部ブログ表示</h3> | |
<?php // Get RSS Feed(s) | |
include_once(ABSPATH . WPINC . '/rss.php'); | |
$rss = fetch_rss('フィードのパス'); | |
$maxitems = 5; | |
$items = array_slice($rss->items, 0, $maxitems); | |
?> | |
<ul> | |
<?php if (empty($items)) : ?> | |
<li>投稿はありません。</li> | |
<?php else: ?> | |
<? foreach ( $items as $item ) :?> | |
<? | |
// 投稿日の取得 | |
$time = $item['pubdate']; | |
$time = strtotime($time); // Unixタイムスタンプ | |
$date = date('Y年m月d日 H:i:s', $time); | |
?> | |
<li> | |
<?php echo $date; ?><br /> | |
<a href="<?php echo $item['link']; ?>" title="<?php echo $item['title']; ?>"><?php echo $item['title']; ?></a><br /> | |
<?php echo strip_tags(mb_substr($item['summary'], 0, 60)) ?> | |
</li> | |
<?php endforeach; ?> | |
<?php endif; ?> | |
</ul><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>無題ドキュメント</title> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment