回顾

换了叶子的新主题,添加了《说说》挂件,做个记录。

原来可以开启子主题,修改下,完美。

子主题文件目录

1,复制static目录一整份(视主题而定)

2,空白style.css

3,sidebar-right.php

4,空白functions.php

添加《说说》style.css

/*
Template: 主题名字
*/
@import url("../主题/style.css");
body.yeziting-dark-mode .microblog-post-list{color:#D3D3D3!important}
body.yeziting-dark-mode .microblog-post-list li{border-bottom:none}
body.yeziting-dark-mode .microblog-post-list li a{color:#fff}
.microblog-post-list{float:left;overflow:hidden;margin-right:1.5em;margin-left:1.5rem;font-size:12px;list-style:none;color:#444}
.microblog-post-list li{margin-bottom:5px;padding-bottom:5px;margin-left:0px;background:url(t.png) no-repeat 0 4px;background-position:0px 5px;text-indent:1.8em;border-bottom:1px dotted #eee}

sidebar-right.php代码部分

<aside id="sidebar-right">
<div class="widget yeziting_post" style="font-size: 14px">
<div style="height: 38px">
<?php
if ( is_user_logged_in() ) {
echo '<a href="/microblog" title="说句话"><h3>说 说</h3></a>';
} else {
echo '<h3>说 说</h3>';
}
?>
</div>
<div class="microblog-post-list">
<?php
$page_ID=420; //用来作为公告栏的页面或者文章id
$num=3; //显示公告的条数
?>
<?php
$announcement = '';
$comments = get_comments("number=$num&post_id=$page_ID");
if ( !empty($comments) ) {
foreach ($comments as $comment) {
$announcement .= '<li>'. convert_smilies($comment->comment_content) . '<br/><a href="/reader#respond"><span style="color:#007bff">发表于:' . get_comment_date('Y/m/d H:i',$comment->comment_ID) . '</span></a></li>';
}
}
if ( empty($announcement) ) $announcement = '<li>欢迎光临本博!</li>';
echo $announcement;
?>
</div>
</div>

functions.php 代码

<?php

function add_style() {

wp_enqueue_style( 'yeziting-style', get_stylesheet_uri() );

}

add_action( 'wp_enqueue_scripts', 'add_style' );

?>