WordPress 页面打理简记(插件编辑小结)

博客页面也有段时间没有打理了,趁今天有空集中整理一次。作为备忘简单记录如下(有些是之前已经修改过的,这里也一并写出作为备忘):

一、使用 Really Simple SSL 插件完成 SSL 配置,详细步骤如下:

  1. 申请并下载证书,我使用的是阿里云的免费证书;
  2. 由于我的 nginx conf 配置文件是放在 vhost 中的单独文件(也就是使用nginx.conf 结尾的 include vhost/*.conf; 生效),所以直接复制一份并按照阿里云中的模板进行修改。阿里云提供的模板如下:
    server {
        listen 443;
        server_name localhost;
        ssl on;
        root html;
        index index.html index.htm;
        ssl_certificate   cert/1526671982448.pem;
        ssl_certificate_key  cert/1526671982448.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        location / {
            root html;
            index index.html index.htm;
        }
    }
    
  3. 安装 Really Simple SSL 并启用;
  4. 使用 https://www.ssllabs.com/ssltest/ 进行检测;
  5. 修改搜索引擎检索配置,如 Google Search Console 和 Google Analytics。

 

二、安装并使用 SyntaxHighlighter Evolved 对代码进行高亮显示处理

由于更新了wordpress 提示使用 Gutenberg 作为编辑器,然而尝试了一段时间并不适应。之后又尝试了最近比较火的 TinyMCE Advanced,发现虽然多了不少功能,但和我现在使用的外观主题不太兼容,就比如代码块功能显示出来效果非常差。最终确定单独使用 SyntaxHighlighter Evolved 作为辅助插件。这里主要介绍使用这个插件需要注意的几个事项:

  1. 关于页面中显示 “帮助” 的去除方式:在编辑插件中,修改如下文件:
    syntaxhighlighter/syntaxhighlighter3/styles/shCore.css
    添加最后一行的:display: none; 即可
    【注意:插件更新后需再次修改添加】

    .syntaxhighlighter .toolbar {
      position: absolute !important;
      right: 1px !important;
      top: 1px !important;
      width: 11px !important;
      height: 11px !important;
      font-size: 10px !important;
      z-index: 10 !important;
      display: none;    // add this line
    }
    

    参考链接:https://www.cnblogs.com/shenjieblog/p/5061097.html

  2. 关于使用方法,经过反复尝试最终发现使用方括号的形式:

    最为稳妥,可直接用 “可视化” 方式实现。其中 lang= 表示高亮语言识别,详细的支持语言列表以及使用方式参考以下链接:
    https://en.support.wordpress.com/code/posting-source-code/
    http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/
    http://alexgorbatchev.com/SyntaxHighlighter/manual/configuration/
  3. 需要关闭其他的虚拟编辑器插件,例如:TinyMCE Advanced。理由如下:
    TIP: Don’t use the Visual editor if you don’t want your code mangled. TinyMCE will “clean up” your HTML.
  4. 貌似在 chrome 浏览器中编辑文章时按 ctrl-z 也会导致 html 关键字替换为转义符,理由同第3点。

 

三、通过修改 single.php 实现文章页面下显示本文链接:

由于目前使用的外观主题没有提供增加本文链接的功能,所以这里采用修改主题 single.php 的方式。在 仪表盘 -> 外观 -> 编辑 里选中 “文章页面” (single.php),在 </div> <!– /post-content –> 前添加如下代码即可:

<p>&nbsp;</p>
<p style="color:gray">{ 本文链接: <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>;
原创文章, 转载请保留. 转载自 <a href="<?php echo get_bloginfo( 'wpurl' ); ?>"><?php echo get_bloginfo( 'name' ); ?></a> }
</p>

 

四、在网站中添加ICP备案标识,参考:
https://www.wpdaxue.com/wordpress-theme-add-icp-beian.html
文章中写的是在footer.php中添加,而我由于主页瀑布效果的缘故直接加在了header.php当中,代码如下:

<p><?php echo get_option( 'zh_cn_l10n_icp_num' );?>.</p>

 

五、修改摘要长度

在模板函数 functions.php 中加入以下代码,其中return 80即为摘要长度80字(包括字母及中文):

function custom_excerpt_length( $length ) {
return 80;
}
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

 

{ 本文链接: https://www.sy2k.com/2018/wordpress-%e9%a1%b5%e9%9d%a2%e6%89%93%e7%90%86%e7%ae%80%e8%ae%b0/;
原创文章, 转载请保留. 转载自 https://www.sy2k.com }

← Previous post

Next post →

4 Comments

  1. UEETEK Nail Grinder Price

    Hey would you mind letting me know which hosting company you’re utilizing?
    I’ve loaded your blog in 3 completely different internet browsers and I
    must say this blog loads a lot quicker then most. Can you suggest a
    good web hosting provider at a reasonable price?

    Cheers, I appreciate it!

admin进行回复 取消回复

邮箱地址不会被公开。

17 − 5 =