论坛有人问能否做一个显示微博的单页面,之前我写过一个Typecho的,现在特地转到WP中来。
复制一下代码命名为microblog.php上传到你当前主题文件夹中
<?php
/*
Template Name:Microblog
*/
?>
<?php get_header(); ?>
<div class="grid_10" id="content">
<div class="post">
<ul class="pagecookery_list">
<li id="panel"><span style="float:left;"><a href="http://pagecookery.net" target="_blank">怡红别院</a><span style="font-size:10px;font-family:"Lucida Grande",Verdana,Arial;"><a href="http://pagecookery.net/">http://pagecookery.net/</a></span></span><a href="http://pagecookery.net/?act=login" target="_blank">登录</a> | <a href="http://pagecookery.net/?act=comments" target="_blank">评论</a> | <a href="http://pagecookery.net/?act=following" target="_blank">关注</a></li>
<?php
$xmlfile = "http://pagecookery.net/rss.xml";
$xml = simplexml_load_file($xmlfile);
$n="20";
for($i=0;$i<$n;$i++){
?>
<li>
<div id="entry-<?php echo $i;?>" class="entry">
<?php echo $xml->channel->item[$i]->description;?><span class="entry-meta" id="entry-meta"><a href="<?php echo $xml->channel->item[$i]->link; ?>"><?php echo $xml->channel->item[$i]->title;?></a></span>
</div>
</li>
<?php }?>
</ul>
</div>
</div><!-- end #content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
然后在WP后台添加新页面,在高级选项的自定义模板中选择刚才上传的Microblog就可以了。
然后对于我这个模板您最后修改一下您的PageCookery的RSS输出样式。具体是将如下代码保存为rss_update.php并上传覆盖掉cron/rss_update.php文件。
<?php
ob_start();
$entry = $SQL->RunQuery("SELECT * FROM entry ORDER BY time DESC LIMIT 0, 50");
$title = SITE_NAME . ' - RSS';
echo urldecode('%3C%3Fxml+version=%221.0%22+encoding=%22utf-8%22%3F%3E');
?><rss version="2.0">
<channel>
<title><?php echo $title; ?></title>
<link><?php echo BASE_URL; ?></link>
<description>Powered by PageCookery Microblog v<?php echo $pcm_version; ?> Build <?php echo $pcm_build; ?></description>
<language>zh</language>
<?php while ($item = $SQL->FetchArray($entry)) { ?>
<item>
<title><?php echo Format::Time($item['time'], 1); ?> 来自 <?php echo $item['from']; ?></title>
<link><?php echo BASE_URL; ?>?act=view&id=<?php echo $item['id']; ?></link>
<description>< ![CDATA[<?php echo $item['content']; ?>
<?php $item['picture'] = $SQL->QueryRowsArray("SELECT * FROM picture WHERE entryid = " . $item['id']); ?>
<?php if ($item['picture']['id']) { ?>
<p class="image"><a href="<?php echo get_picture_url($item['picture']['id'], 'o'); ?>" title="<?php echo $item['picture']['filename']; ?>"><img src="<?php echo get_picture_url($item['picture']['id'], 'm'); ?/>" alt="<?php echo $item['picture']['filename']; ?>" /></a></p>
<?php } ?>]]></description>
<pubdate><?php echo Format::Date($item['time'], 'D, j M Y H:i:s' , 0); ?> +0000</pubdate>
</item>
<?php } ?>
</channel>
</rss>
<?php
$data = ob_get_contents();
ob_end_clean();
file_put_contents('rss.xml', $data);
最后附上我的样式表,复制下列代码到WP当前主题的style.css中即可。
.pagecookery_list {
list-style-type:disc;
font-size:14px;
color:#666666;
line-height:1.7;
font-family:Georgia,Times,"Times New Roman",serif;
}
.pagecookery_list li {
border-bottom:1px dashed #CCCCCC;
list-style-type:none;
padding:5px 0;
margin:0;
}
.pagecookery_list li:hover {
background:none repeat scroll 0 0 #E7E7E7;
}
.pagecookery_list li img {
width:100px;
}
.pagecookery_list a {
color:#999999;
}
.entry-meta {
background:url("https://p.upyun.lithub.cc/404.png?url=http%3A%2F%2Fstorage.live.com%2Fitems%2F8AAEE749DE3922BE!558%3Ffilename%3Ddigu-time.png") no-repeat scroll 0 0 transparent;
padding:0 0 0 19px;
}
.entry-meta a {
border-bottom:none;
}
.entry-meta a:hover {
color:#FF6633;
}
#panel {
text-align:right;
}
#panel:hover {
background:none;
}
#panel a {
border:none;
padding:2px 5px;
}
#panel a:hover {
color:#FF6633;
background:none repeat scroll 0 0 #E7E7E7;
}
PS 能把我链接改改不==…
汗,改好了…
想不起来的 貌似今天从豆瓣九点点了一个链接 是你这的
可是现在那日志没了
而且表情也不一样==
==恩,对此事表示不明白…
好吧 我自己找历史 果然还是你这里
http://blog.imnerd.org/install-php-in-ubuntu.html
这个==
:9 尴尬,我新开了个小博而已……= =
:11 定时发布
==!汗,不是定时发布额…