首页 > CMS > Wordpress > 正文

WP wiki插件的固定地址重写

2024-09-07 00:51:54
字体:
来源:转载
供稿:网友

最近的项目使用到了这个插件,主要是为WP提供一个wiki百科功能,插件是收费的:传送门.

遇到的问题是固定地址使用的是/%postname%/的方式,中文标题对百度搜录不利,所以想办法要把结构变成/%post_id%.html,所以就找了一些教程写了一个规则,可以把固定连接改成wiki/post id.html的方式:

  1. add_filter('post_type_link''custom_wiki_link', 1, 3); 
  2. function custom_wiki_link( $link$post = 0 ){ 
  3. if ( $post->post_type == 'incsub_wiki' ){ 
  4. return home_url( 'wiki/' . $post->ID .'.html' ); 
  5. else { 
  6. return $link
  7. add_action( 'init''custom_wiki_rewrites_init' ); 
  8. function custom_wiki_rewrites_init(){ 
  9. add_rewrite_rule(  //Vevb.com 
  10. 'wiki/([0-9]+)?.html$'
  11. 'index.php?post_type=incsub_wiki&p=$matches[1]'
  12. 'top' ); 

加入functions就起作用了~

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表