显示PC的最近消息模板


<p>论坛有人问能否做一个显示微博的单页面,之前我写过一个Typecho的,现在特地转到WP中来。</p><p>
</p><p>复制一下代码命名为microblog.php上传到你当前主题文件夹中</p>

< ?php
/*
Template Name:Microblog
*/
?>
< ?php get_header(); ?>
<div class="grid_10" id="content">
<div class="post">
  • <span style="float:left;">怡红别院<span style="font-size:10px;font-family:"Lucida Grande",Verdana,Arial;">http://pagecookery.net/</span></span>登录 | 评论 | 关注
  • < ?php $xmlfile = "http://pagecookery.net/rss.xml"; $xml = simplexml_load_file($xmlfile); $n="20"; for($i=0;$i<$n;$i++){ ?>
  • <div id="entry-<?php echo $i;?>" class="entry"> < ?php echo $xml->channel->item[$i]->description;?><span class="entry-meta" id="entry-meta"></span> </div>
  • < ?php }?>

</div>
</div><!-- end #content-->
< ?php get_sidebar(); ?>
< ?php get_footer(); ?>
</pre>
<p>然后在WP后台添加新页面,在高级选项的自定义模板中选择刚才上传的Microblog就可以了。</p>
<p>然后对于我这个模板您最后修改一下您的PageCookery的RSS输出样式。具体是将如下代码保存为rss_update.php并上传覆盖掉cron/rss_update.php文件。</p>

< ?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') { ?>
<p class="image"></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);

<p>最后附上我的样式表,复制下列代码到WP当前主题的style.css中即可。</p>
</pre><pre lang="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("http://storage.live.com/items/8AAEE749DE3922BE!558?filename=digu-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;
}

显示PC的最近消息模板》上有 8 条评论

  1. 想不起来的 貌似今天从豆瓣九点点了一个链接 是你这的
    可是现在那日志没了
    而且表情也不一样==

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注