wordpress插件
插件列表
- 删掉默认插件
- 先装该插件,WP Super Cache:启动就可以了
- Redis Object Cache:启动就可以了
- Autoptimize:可以压缩html,去掉注释。与 WP Super Cache 插件无冲突.设置优化JS,CSS,HTML
- Companion Auto Update:本插件可自动更新所有插件、主题与 WordPress 内核。自动更新所有
- WP Githuber MD:一个为 WordPress 网站提供全功能 Markdown 语法的插件。
- Disable XML-RPC-API:Lightweight plugin to disable XML-RPC API and Pingbacks,Trackbacks for faster and more secure website.关闭Enable xml-rpc for Jetpack
- Wordfence Security – Firewall & Malware Scan:安全插件
- Custom Taxonomy Order: 可以调整分类等的顺序
- One User Avatar:使用您媒体库的任一图像作为自定义用户头像,添加自定义默认头像。
- Fixed Widget:使用 fixed widget小工具插件来创建粘性窗口小工具,这些页面在向上或向下滚动页面时会停留在可见的屏幕区域中,从而提高转化率。
- WP Mail SMTP
- WPS Hide Login:通过更改登录URL并在未登录时阻止访问wp-login.php页面和wp-admin目录来保护您的网站
- Yet Another Related Posts Plugin (YARPP):Adds related posts to your site and in RSS feeds, based on a powerful, customizable algorithm.
- Google Analytics for WordPress by MonsterInsights:Google网站分析插件,这之前需要在 Google Analytics上添加网站。
- Theme Check:检查主题,如果用的是wordpress官方主题,实际上可以不考虑安装。
- WP Statistics: 统计分析
- Bulk Delete:批量删除帖子等
插件WP Githuber MD 的代码显示行号的问题
参考解决Githuber MD插件代码高亮不能正常工作的问题:
- 安装Enlighter - Customizable Syntax Highlighter插件。
- 在主题中添加HTML标签转换的PHP代码:找到主题的 inc/theme-core.php文件,打开之后将这段代码复制进去,保存即可。复制代码时主要把代码放在
<?php>
标签内。
function getPar($par,$str){ $pieces = preg_split($par, $str,-1,PREG_SPLIT_DELIM_CAPTURE); $result =''; foreach($pieces as $piece){ $result.=$piece; } return $result; } //转换代码高亮器 function bTagFilter($content) { $pattern_full = '{(<pre><code class="language-[sS]*?">[sS]*?</code></pre>)}'; $pattern_full1 ='{<pre><code class="language-[sS]*?">([sS]*?)</code></pre>}'; $pattern_full2 ='{<pre><code class="language-([sS]*?)">[sS]*?</code></pre>}'; //使用短代码的正则分割字符串 $pieces = preg_split($pattern_full, $content,-1,PREG_SPLIT_DELIM_CAPTURE); $new_content = ''; //遍历所有的字符串 含有段代码的字符串不做自动处理 foreach($pieces as $piece) { if (preg_match($pattern_full, $piece, $matches)) { $code = $matches[0]; $lug = getPar($pattern_full2,$piece); $code = getPar($pattern_full1,$piece); $code = '<pre class="EnlighterJSRAW" data-enlighter-language="'.$lug.'">'.$code.'</pre>'; $new_content .= $code; } else { $new_content .= $piece; } } return $new_content; } add_filter('the_content', 'bTagFilter', 99);
插件WP Githuber MD 任务列表显示异常
列表项目之间不能有空行,如下列表就会显示异常
- [ ] item1 - [ ] item2 - [ ] item3
插件 WP Githuber MD + python 脚本编写博客
wordpress插件 WP Githuber MD 在做具体的转换时,有时候会有一些问题, 所以只用插件的编辑和预览功能,用python脚本生成最后更新的post的html:
- python脚本持续运行,获取最后被修改的post的最后修改时间
- 如果最后修改时间有变,用python脚本将 post_content_filtered 的Markdown内容转换为 html,并用python脚本更新post_content 内容为 html,更新最后修改时间
- cron监控python脚本持续运行
sql 转义导致高亮代码显示异常
不应该修改sql转义规则,而是修改前端的显示内容,主题的 single.php 文件添加如下代码:
测试
目录
公式
插件Redis Object Cache 不自动更新
1.设置wordpress
参考: https://github.com/rhubarbgroup/redis-cache/wiki/Configuration-Options
编辑 wp-config.php,
// WP_REDIS_MAXTTL (default: not set) // Set maximum time-to-live (in seconds) for cache keys with an expiration time of 0. define( 'WP_REDIS_MAXTTL', '360' );
2.设置redis并重启
- 关闭 appendonly
- 设置 appendfsync 为 no
- 更改配置文件,并重启 redis
save "" #save 900 1 #save 300 10 #save 60 10000
3.php 版本安装对应的 redis插件
- wordpress 后台设置 redis插件,flush cache
wordpress主题
wordpress 上传主题报错: ERR_HTTP2_PROTOCOL_ERROR
可能是宝塔面板的 Nginx免费防火墙 导致的,关闭它。
wordpress主题:Kratos
安装
https://github.com/seatonjiang/kratos/releases
配置
- 全站配置,功能配置,特色图片,禁用
- 顶部配置,图片导航,关闭
- 文章配置,关闭相关展示功能;页面布局:单列布局
首页按文章最后修改时间排序
index.php
if (have_posts()) { $posts = query_posts($query_string . '&orderby=modified'); while (have_posts()) { the_post(); get_template_part('/pages/page-content', get_post_format()); } }
wordpress主题:CorePress(已弃用)
fork from: https://github.com/ghboke/CorePressWPTheme
修改版本: https://github.com/rankment/CorePressWPTheme
常规设置
- logo
- favicon:直接上传到wordpress根目录
- 自动缩略图:关闭
文章设置
- 不显示缩略图
- 默认开启目录:开启(默认会显示在左侧边栏)
功能模块
- 复制成功自动添加来源网址
- 引导外部浏览器打开
用户中心
隐藏登录注册按钮
优化加速
- 头像服务器:七牛CDN
- 自定义CDN功能使用,参考: https://www.yuque.com/applek/corepress/customcdn
从 https://github.com/rankment/corepresscdn 下载 zip 文件,将static文件夹通过宝塔面板上传到 wordpress根目录
自定义CDN地址设置为 https://rankment.com (URL尾部不带/
,开头为https)
CorePress主题模仿Mac样式
参考 https://www.lovestu.com/corepressmac.html
免费版用户将此段CSS代码,加入到主题设置,插入代码,自定义CSS,即可
:root { --border-hd: 10px !important; } body header { box-shadow: 0 0 20px 0 rgb(0 0 0 / 5%); } .post-list-page-plane { background-color: #fff; } body .widget-title { border-bottom: none; } .friend-links { overflow: hidden; } body .widget-title:before { width: 12px; height: 12px; transform: none; background: #fc625d; border-radius: 50%; top: 10px; } body .widget-title:after { background-color: #fdbc40; width: 12px; height: 12px; transform: none; border-radius: 50%; left: 20px; top: 10px; } body .widget-title { padding-left: 40px; } .widget-admin-author-contact-item-icon { border-bottom-left-radius:2px!important; }
隐藏首页作者头像
post-list-item.php
// $postitem['author_avatar'] = '<img alt="" src="' . corepress_get_avatar_url(get_the_author_meta('email'), 24) . '" class="post-item-avatar">'; $postitem['author_avatar'] = '';
按文章最后修改时间排序
存在的问题:分类显示错误
post-main-index.php, 添加 posts 定义:
if (have_posts()) { $posts = query_posts($query_string . '&orderby=modified'); while (have_posts()) { the_post(); get_template_part('component/post-list-item'); } }
文章评论