<pre class="wp-block-code">```
* {
margin: 0;
outline: none;
line-height: 30px;
border: 0 none;
}
p {
text-indent: 30px;
padding-bottom:14px;
text-align: justify;
}
p a {
border-bottom: 1px solid;
}
p a:hover {
color: red;
}
h1,
h2,
h3,
h4,
h5,
h6 {
padding-bottom:20px;
}
article h2 {
border-top: solid 1px #ccc;
margin-top:20px;
padding-top:30px;
}
article img {
margin-top:10px;
}
## 无代码开启WordPress文章关键字内链
直接添加Functions.php脚本实现自动Tags内链效果,但是这样的脚本有些问题,比如我们在升级主题或者更换主题的时候还需要重新替换。****TaxoPress****插件可以实现类似功能。
class="wp-block-code">``` //自动TAG转内链 $match_num_from = 1; // 一个TAG标签出现几次才加链接 $match_num_to = 1; // 同一个标签加几次链接 add_filter('the_content','tag_link',1); function tag_sort($a, $b){ if ( $a->name == $b->name ) return 0; return ( strlen($a->name) > strlen($b->name) ) ? -1 : 1; } function tag_link($content){ global $match_num_from,$match_num_to; $posttags = get_the_tags(); if ($posttags) { usort($posttags, "tag_sort"); foreach($posttags as $tag) { $link = get_tag_link($tag->term_id); $keyword = $tag->name; $cleankeyword = stripslashes($keyword); $url = "<a href=\"$link\" title=\"".str_replace('%s',addcslashes($cleankeyword, '$'),__('查看更多 for %s'))."\""; $url .= ' target="_blank"'; $url .= ">".addcslashes($cleankeyword, '$')."</a>"; $limit = rand($match_num_from,$match_num_to); $content = preg_replace( '|(<a[^>]+>)(.*)('.$ex_word.')(.*)(</a[^>]*>)|U'.$case, '$1$2%&&&&&%$4$5', $content); $content = preg_replace( '|(<img)(.*?)('.$ex_word.')(.*?)(>)|U'.$case, '$1$2%&&&&&%$4$5', $content); $cleankeyword = preg_quote($cleankeyword,'\''); $regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s' . $case; $content = preg_replace($regEx,$url,$content,$limit); $content = str_replace( '%&&&&&%', stripslashes($ex_word), $content); } } return $content; } ``` ``` - - - - - - ## Simple Writer主题修改 ### Simple Writer修改记录 - 隐藏分类及简介: 自定义 ▸ Theme Options Archive Pages Options,Hide Category Title + Category Description from Category Archive Pages - 调节banner尺寸和文字: 自定义 ▸ Theme Options Header Options,设置header都 height和Padding值。 ### style.css修改 自定义 ▸ 额外CSS——这种修改不怕主题升级;更换主题失效。 ```class="wp-block-code">``` article h2 { border-top: dotted 1px #ccc; margin-top:20px; padding-top:30px; } .entry-content a:hover,.entry-content a:focus,.entry-content a:active{text-decoration:none;color:#ea5029;} li a{border-bottom:1px dotted #c94f31;} ``` ``` ### 底部版权信息: 后台编辑的主题Simple Writer文件: 主题页脚 (footer.php) : ```class="wp-block-code">```