我可以有一个数字的wordpress固定链接吗?尝试强制永久链接为"2“,例如自动将其重写为"2-2”。
进一步研究一下,我发现这是任何数字固定链接的情况-我认为它与可能的分页干扰有关,但有一个我想要使用此结构的用例。
发布于 2011-11-05 11:18:55
我已经处理过一次,通过截取post插件创建并以某种方式“修复”它。也许你可以这样做:
/*
* New permalink structure
*
* Itercepts every wp_insert_post data to change the regular slugs to md5 hashes
* based on the Unix timestamp of action. This generates a new slug at every
* saving action, which protects the posts against unauthorised direct access.
*
*/
function rm_cpt_permalink_change($data) {
if ($data['post_type'] == 'custom_post_type') {
$time = time();
$data['post_name'] = md5($time);
return $data;
} else {
return $data;
}
}
add_filter('wp_insert_post_data','rm_cpt_permalink_change',10,2);
你真的需要个位数的弹头吗?如果你能在00001或000005上如愿以偿,那么wp_insert_post_data
过滤器可能就是不错的选择。
发布于 2012-08-23 22:50:19
实际上,这可以从设置中的固定链接部分轻松完成。您只需将/post_id/设置为固定链接结构,它就会工作得很好。
发布于 2011-11-05 01:53:01
您可能已经有一个带有slug‘2’的帖子;如果它不在帖子管理面板中,那么它可能还在垃圾桶中。
另外,使用数字作为slug可能不是最好的主意--它可能会与分页和其他重写规则冲突,并且可能无法描述该帖子的用途。
希望这能有所帮助!
https://stackoverflow.com/questions/8007881
复制相似问题