找回wordpress丢失已久的后台链接功能

最近想增加友情链接功能,发现最新的WP不知哪个版本把链接功能去掉了,WTF,只能重新找回这个功能。

仪表盘 — 外观 — 编辑

在模版函数(functions.php)的代码最后一行添加
add_filter( ‘pre_option_link_manager_enabled’, ‘__return_true’ );

最后点击“更新文件”,即可看到久违的链接图标

wordpress使用固定链接

环境:Ubuntu 14.04, wordpress 4.7.1,  Apache/2.4.7

由于wordpress本身的链接方法就是?p=1这种方法,不利于搜索引擎索引,因而使用固定链接方法。步骤如下:

  1. 启用urlrewrite, sudo a2enmode rewrite
  2. vi /etc/apache2/apache2.conf,搜索AllowOverride None,将None修改成All
  3. 重启apache2, sudo service apache2 restart
  4. 登录到wordpress后台,“设置”-》“固定链接”-》“月份和名称型”, 然后在服务器上的目录/var/www/wordpress下创建.htaccess文件,并将后台页面最下面的.htaccess的内容复制的到.htaccess文件内。

到此wordpress的固定链接已经打通。

wordpress 数据库postgresql迁移至mysql

环境: Ubuntu 14.04, postgresql 9.3, mysql 5.5, wordpress 4.7.1

之前用wordpress 3.4.2和postgresql, pg4wp搭建一个个人博客网站,后来想升级时发现pg4wp从1.3.1之后再也没升级过,这个比较坑了,后续的wordpress都没法再升级上去。没办法,硬着头皮把postgresql替换成mysql。

#postgresql operations,从postgresql上导出数据
\copy wp_postmeta to ‘/home/jerry/postmeta.txt’;
\copy wp_posts ‘/home/jerry/posts.txt’;
\copy wp_links ‘/home/jerry/links.txt’;
\copy wp_terms ‘/home/jerry/terms.txt’;
\copy wp_term_relationships ‘/home/jerry/terms_relationships.txt’;
\copy wp_term_taxonomy ‘/home/jerry/terms_taxonomy.txt’;

 

#mysql operations,新建数据库wordpress, 并导入之前的数据
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

delete from wp_postmeta;
delete from wp_posts;
delete from wp_links;
delete from wp_terms;
delete from wp_term_relationships;
delete from wp_term_taxonomy;

load data infile ‘/home/jerry/postmeta.txt’ into table wp_postmeta;
load data infile ‘/home/jerry/posts.txt’ into table wp_posts;
load data infile ‘/home/jerry/links.txt’ into table wp_links;
load data infile ‘/home/jerry/terms.txt’ into table wp_terms;
load data infile ‘/home/jerry/terms_relationships.txt’ into table wp_term_relationships;
load data infile ‘/home/jerry/terms_taxonomy.txt’ into table wp_term_taxonomy;