固定链接更改wordpress中的每个帖子更新 [英] Permalink change each post update in wordpress

查看:130
本文介绍了固定链接更改wordpress中的每个帖子更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为WordPress中的每个新帖子提供一个自定义的永久链接,例如: http://mysite.com/x5Kvy6.

I want to have a custom permalink for each new post in WordPress like: http://mysite.com/x5Kvy6.

function wp_unique_post_slug($col,$table='wp_posts'){
     global $wpdb;

     $alphabet = array_merge( range(0, 9), range('a','z') );

     $already_exists = true;
     do {

         $guidchr = array();
         for ($i=0; $i<32; $i++)
         $guidchr[] = $alphabet[array_rand( $alphabet )];


         $guid = sprintf( "%s", implode("", array_slice($guidchr, 0, 12, true)) );

       // check that GUID is unique
       $already_exists = (boolean) $wpdb->get_var("
       SELECT COUNT($col) as the_amount FROM $table WHERE $col = '$guid'
       ");

      } while (true == $already_exists);

     return $guid;
}

当我替换post.php(wordpress核心)中的字体时,此脚本运行良好,但不幸的是,每次更新后,永久链接都会更改. 如何避免这种情况?以及如何编辑自定义可选关键字(http://mysite.com/keyword).

This script works well when i replace the fontion in post.php (wordpress core) but unfortunately the permalink change at each post uptade. How to avoid this? And how to edit a custom optional keyword (http://mysite.com/keyword).

欢迎提出任何想法!

推荐答案

您想尝试此插件.

http://wordpress.org/extend/plugins/custom-permalinks/

这篇关于固定链接更改wordpress中的每个帖子更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆