wordPress建站

2023年4月7日 1072点热度 0人点赞

开始

最近又开始折腾了域名、博客、服务器,之前我买的域名是与我的github博客crayfishxu.github.io绑定在一起的,近期搞了好几台甲骨文的服务器,首页在服务上装了宝塔面板,方便操作。

安装WordPress

首先在宝塔上新建“站点”,域名可以填写IP、顶级域名、二级域名,FTP和数据库自行选择安装。

新建完“站点”,将下载好的wordpress-5.9.3-zh_CN.zip版本上传至根目录。

随后解压文件,把wordpress文件夹下的文件拷贝到根目录,删除wordpress文件夹。

然后选择一个自己喜欢的主题进行配置,可以去主题商城添加。

然后我配置了Rank Math SEO、缓存优化、markdown优化插件,一下子提升了WP的使用便捷性。

Rank Math SEO

使用站点地图的过程中遇到了无法正常收录的问题,我研究着改造了Rank Math的sitemap.xml输出方式。如下:
插件目录seo-by-rank-math/includes/modules/sitemap,找到class-generator.php文件修改get_output方法。

/**
 * Produce final XML output with debug information.
 *
 * @param  string $type Sitemap type.
 * @param  int    $page Page number to retrieve.
 * @return string
 */
public function get_output( $type, $page ) {
    $output = '<?xml version="1.0" encoding="' . esc_attr( $this->get_output_charset() ) . '"?>';
    if ( $this->stylesheet ) {
        /**
         * Filter the stylesheet URL for the XML sitemap.
         *
         * @param string $stylesheet Stylesheet URL.
         */
        $output .= $this->do_filter( "sitemap/{$type}_stylesheet_url", $this->stylesheet ) . "\n";
    }
    $content = $this->build_sitemap( $type, $page );
    if ( '' !== $content ) {
        return (去除$output).$content;
    }
    return '';
}

CrayfishXu

提供Switch游戏资源,最新最全短剧资源,各类资讯