【问题标题】:Add score to wordpress custom post type slug将分数添加到 wordpress 自定义帖子类型 slug
【发布时间】:2019-09-12 11:52:20
【问题描述】:

我的自定义帖子类型“有效”有以下代码,但当前代码不允许链接上的分数“-”?我应该解决什么问题?

function works_rewrites_init($post_link, $post = 0){

  add_rewrite_rule('works\/([A-Za-z0-9]+)?\/([0-9]+)?(page\/)?([0-9]+)?\/?$', 'index.php?paged=$matches[4]&post_type=works&workscat=$matches[1]&p=$matches[2]', 'top');
}

【问题讨论】:

    标签: wordpress permalinks slug


    【解决方案1】:
    function works_rewrites_init($post_link, $post = 0){
        $rule = 'works\/([A-Za-z0-9\-]+)?\/([0-9]+)?(page\/)?([0-9]+)?\/?$';
      $pageID = $post->ID;
      add_rewrite_rule($rule, 'index.php?paged=$matches[4]&post_type=works&workscat=$matches[1]&p=$matches[2]', 'top');
    }
    add_action('init', 'works_rewrites_init');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-01-31
      • 2011-11-19
      • 2013-08-04
      • 2017-11-27
      • 2015-05-06
      • 1970-01-01
      • 1970-01-01
      • 2017-03-03
      相关资源
      最近更新 更多