问题描述

我一直试图通过学习分类法的内容和方法,以及如何将它们整合到主题中,我遇到了一个我似乎无法想象的一个非常基本的问题。

我开始在 BuddyPress 安装中使用更多分类法进行工作。在无法使用平台的重写块 (taxonomy-platform.php) 加载自定义模板… www.mydomain.com/wpinstall/platform …. 我删除了更多分类法的分类法 (但不是条目在数据库中的条款),卸载更多分类法,并进入我的 Buddypress functions.php 分类。

首先我用

    //hook into the init action and call create_platform_taxonomies when it fires
add_action( 'init', 'create_platform_taxonomies', 0);
//create the non-heirarchical Platforms taxonomy
function create_platform_taxonomies()
{


  // Adding a taxonomy for Platforms, non heirarchical
$labels = array(
    'name' => _x( 'Platforms', 'taxonomy general name' ),
    'singular_name' => _x( 'Platform', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Platforms' ),
    'popular_items' => __( 'Popular Platforms' ),
    'all_items' => __( 'All Platforms' ),
    'parent_item' => null,
    'parent_item_colon' => null,
    'edit_item' => __( 'Edit Platform' ),
    'update_item' => __( 'Update Platform' ),
    'add_new_item' => __( 'Add New Platform' ),
    'new_item_name' => __( 'New Platform Name' ),
    'separate_items_with_commas' => __( 'Separate platforms with commas' ),
    'add_or_remove_items' => __( 'Add or remove platforms' ),
    'choose_from_most_used' => __( 'Choose from the most used platforms' ),
    'menu_name' => __( 'Platforms' ),
  );

  register_taxonomy('platform',
    array( 'post', 'page', 'mediapage', 'attachment', 'revision', 'nav_menu_item', 'cheats', 'reviews', 'tutorials' ),
        array(
            'hierarchical' => false,
            'labels' => $labels,
            'show_ui' => true,
            'query_var' => true,
            'rewrite' => array( 'slug' => 'platform' ),
  ));
}

但仍然不允许它正常工作。

*让我在这里注意到,我已经是 over-zealous 关于在整个过程中使用 「永久链接」 页面保存方法来刷新我的重写。

然后我回滚到 2010 年,并将相同的代码输入 functions.php,并再次尝试相同的结果。分类法显示在所有的帖子类型下,它从数据库中拉出了旧的数据,正确输入了帖子,但是我无法打开 taxonomy-platform.php 页面,总是得到一个 「该页面找不到」 的错误。

所以现在我写了我觉得是一个更加倾倒的分类学,并尝试过;

    add_action( 'init', 'create_testtax_taxonomies', 0);

 function create_testtax_taxonomies()
 {
 register_taxonomy ( 'testtax', array( 'post', ),
    array(
        'hierarchical' => false,
        'labels' => array( 'Testtax', ),
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'testtax' ),
        ));

 }

这显示 (虽然它被称为我的帖子类型中的第二个’Post Tags’,但我认为这是因为我减少了标签这么大),但是当尝试导航到 www.mydomain.com/wpinstall/testtax 时显示相同的行为

这是我的代码为 taxonomy-testtax.php 页面

<?php

/* This is the custom template for
* the platforms taxonomy.
*/

get_header(); ?>

        <div id="container">
            <div id="content" role="main">
hello

            </div><!-- #content -->
        </div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

再次,尽可能的简单,但我也使用索引和其他各种 loop-enabled 页面的副本。

任何帮助将不胜感激,谢谢提前!不知道我是否缺少一些简单的东西,或者在正确启用分类法的情况下跳过一个过程… 只是不确定。




添加一些更多的信息来扩展一些下面的答案/评论 (找不到更有效的方法来做到这一点)

我看到一些关于这种问题的帖子,我注意到有些人能够从 WordPress 冲洗整个软 re-write 规则。我想我会看到我是否可以自己得到同样的打印。首先我补充说

add_action('wp_footer', 'show_rewrite_rules');
function show_rewrite_rules(){
  global $wp_rewrite;
  echo "<pre>";
  print_r($wp_rewrite->rules);
  echo "</pre>";
}

所以,补充说,在 2010 年的我的 Functions.php(我几乎保持我的 2010 主题和我的 BuddyPress 安装/主题 uptodate 与所有这些可能的修复和更改和测试两者都 – 再次禁用插件几次,完成一个保存,因为我已经尝试了下面的一些建议) 。我得到这个输出

Array
(
    [categories/(.+)/search_type/(.+)/order/(.+)/page/(.+)] => index.php?cat=$matches[1]&search_type=$matches[2]&order=$matches[3]&paged=$matches[4]
    [categories/(.+)/search_type/(.+)/order/(.+)] => index.php?cat=$matches[1]&search_type=$matches[2]&order=$matches[3]
    [categories/(.+)/page/(.+)] => index.php?cat=$matches[1]&paged=$matches[2]
    [categories/(.+)] => index.php?cat=$matches[1]
    [promotion/?$] => index.php?post_type=ps_promotion
    [promotion/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_type=ps_promotion&feed=$matches[1]
    [promotion/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_type=ps_promotion&feed=$matches[1]
    [promotion/page/([0-9]{1,})/?$] => index.php?post_type=ps_promotion&paged=$matches[1]
    [category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
    [category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
    [category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
    [category/(.+?)/?$] => index.php?category_name=$matches[1]
    [tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
    [tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
    [tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
    [tag/([^/]+)/?$] => index.php?tag=$matches[1]
    [type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
    [type/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
    [type/([^/]+)/page/?([0-9]{1,})/?$] => index.php?post_format=$matches[1]&paged=$matches[2]
    [type/([^/]+)/?$] => index.php?post_format=$matches[1]
    [cheats/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
    [cheats/[^/]+/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [cheats/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [cheats/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [cheats/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [cheats/([^/]+)/trackback/?$] => index.php?cheats=$matches[1]&tb=1
    [cheats/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?cheats=$matches[1]&feed=$matches[2]
    [cheats/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?cheats=$matches[1]&feed=$matches[2]
    [cheats/([^/]+)/page/?([0-9]{1,})/?$] => index.php?cheats=$matches[1]&paged=$matches[2]
    [cheats/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?cheats=$matches[1]&cpage=$matches[2]
    [cheats/([^/]+)/entry(/(.*))?/?$] => index.php?cheats=$matches[1]&entry=$matches[3]
    [cheats/([^/]+)(/[0-9]+)?/?$] => index.php?cheats=$matches[1]&page=$matches[2]
    [cheats/[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]
    [cheats/[^/]+/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [cheats/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [cheats/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [cheats/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [reviews/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
    [reviews/[^/]+/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [reviews/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [reviews/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [reviews/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [reviews/([^/]+)/trackback/?$] => index.php?reviews=$matches[1]&tb=1
    [reviews/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?reviews=$matches[1]&feed=$matches[2]
    [reviews/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?reviews=$matches[1]&feed=$matches[2]
    [reviews/([^/]+)/page/?([0-9]{1,})/?$] => index.php?reviews=$matches[1]&paged=$matches[2]
    [reviews/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?reviews=$matches[1]&cpage=$matches[2]
    [reviews/([^/]+)/entry(/(.*))?/?$] => index.php?reviews=$matches[1]&entry=$matches[3]
    [reviews/([^/]+)(/[0-9]+)?/?$] => index.php?reviews=$matches[1]&page=$matches[2]
    [reviews/[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]
    [reviews/[^/]+/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [reviews/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [reviews/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [reviews/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [tutorials/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
    [tutorials/[^/]+/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [tutorials/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [tutorials/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [tutorials/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [tutorials/([^/]+)/trackback/?$] => index.php?tutorials=$matches[1]&tb=1
    [tutorials/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tutorials=$matches[1]&feed=$matches[2]
    [tutorials/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tutorials=$matches[1]&feed=$matches[2]
    [tutorials/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tutorials=$matches[1]&paged=$matches[2]
    [tutorials/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?tutorials=$matches[1]&cpage=$matches[2]
    [tutorials/([^/]+)/entry(/(.*))?/?$] => index.php?tutorials=$matches[1]&entry=$matches[3]
    [tutorials/([^/]+)(/[0-9]+)?/?$] => index.php?tutorials=$matches[1]&page=$matches[2]
    [tutorials/[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]
    [tutorials/[^/]+/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [tutorials/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [tutorials/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [tutorials/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [platform/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?platform=$matches[1]&feed=$matches[2]
    [platform/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?platform=$matches[1]&feed=$matches[2]
    [platform/([^/]+)/page/?([0-9]{1,})/?$] => index.php?platform=$matches[1]&paged=$matches[2]
    [platform/([^/]+)/?$] => index.php?platform=$matches[1]
    [testtax/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?testtax=$matches[1]&feed=$matches[2]
    [testtax/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?testtax=$matches[1]&feed=$matches[2]
    [testtax/([^/]+)/page/?([0-9]{1,})/?$] => index.php?testtax=$matches[1]&paged=$matches[2]
    [testtax/([^/]+)/?$] => index.php?testtax=$matches[1]
    [promotion/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
    [promotion/[^/]+/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [promotion/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [promotion/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [promotion/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [promotion/([^/]+)/trackback/?$] => index.php?ps_promotion=$matches[1]&tb=1
    [promotion/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?ps_promotion=$matches[1]&feed=$matches[2]
    [promotion/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?ps_promotion=$matches[1]&feed=$matches[2]
    [promotion/([^/]+)/page/?([0-9]{1,})/?$] => index.php?ps_promotion=$matches[1]&paged=$matches[2]
    [promotion/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?ps_promotion=$matches[1]&cpage=$matches[2]
    [promotion/([^/]+)/entry(/(.*))?/?$] => index.php?ps_promotion=$matches[1]&entry=$matches[3]
    [promotion/([^/]+)(/[0-9]+)?/?$] => index.php?ps_promotion=$matches[1]&page=$matches[2]
    [promotion/[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]
    [promotion/[^/]+/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [promotion/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [promotion/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [promotion/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [promotions/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?promotion-categories=$matches[1]&feed=$matches[2]
    [promotions/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?promotion-categories=$matches[1]&feed=$matches[2]
    [promotions/([^/]+)/page/?([0-9]{1,})/?$] => index.php?promotion-categories=$matches[1]&paged=$matches[2]
    [promotions/([^/]+)/?$] => index.php?promotion-categories=$matches[1]
    [(.+)/entry/%entry%/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?%entry%$matches[1]&feed=$matches[2]
    [(.+)/entry/%entry%/(feed|rdf|rss|rss2|atom)/?$] => index.php?%entry%$matches[1]&feed=$matches[2]
    [(.+)/entry/%entry%/page/?([0-9]{1,})/?$] => index.php?%entry%$matches[1]&paged=$matches[2]
    [(.+)/entry/%entry%/?$] => index.php?%entry%$matches[1]
    [.*wp-atom.php$] => index.php?feed=atom
    [.*wp-rdf.php$] => index.php?feed=rdf
    [.*wp-rss.php$] => index.php?feed=rss
    [.*wp-rss2.php$] => index.php?feed=rss2
    [.*wp-feed.php$] => index.php?feed=feed
    [.*wp-commentsrss2.php$] => index.php?feed=rss2&withcomments=1
    [feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]
    [(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]
    [page/?([0-9]{1,})/?$] => index.php?&paged=$matches[1]
    [comments/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]&withcomments=1
    [comments/(feed|rdf|rss|rss2|atom)/?$] => index.php?&feed=$matches[1]&withcomments=1
    [comments/page/?([0-9]{1,})/?$] => index.php?&paged=$matches[1]
    [search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?s=$matches[1]&feed=$matches[2]
    [search/(.+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?s=$matches[1]&feed=$matches[2]
    [search/(.+)/page/?([0-9]{1,})/?$] => index.php?s=$matches[1]&paged=$matches[2]
    [search/(.+)/?$] => index.php?s=$matches[1]
    [author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2]
    [author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2]
    [author/([^/]+)/page/?([0-9]{1,})/?$] => index.php?author_name=$matches[1]&paged=$matches[2]
    [author/([^/]+)/?$] => index.php?author_name=$matches[1]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&paged=$matches[4]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]
    [([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]
    [([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&feed=$matches[3]
    [([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&paged=$matches[3]
    [([0-9]{4})/([0-9]{1,2})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]
    [([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&feed=$matches[2]
    [([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&feed=$matches[2]
    [([0-9]{4})/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&paged=$matches[2]
    [([0-9]{4})/?$] => index.php?year=$matches[1]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/trackback/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&tb=1
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&feed=$matches[5]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&paged=$matches[5]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&cpage=$matches[5]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/entry(/(.*))?/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&entry=$matches[6]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(/[0-9]+)?/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&page=$matches[5]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&cpage=$matches[4]
    [([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/entry(/(.*))?/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&entry=$matches[5]
    [([0-9]{4})/([0-9]{1,2})/comment-page-([0-9]{1,})/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&cpage=$matches[3]
    [([0-9]{4})/([0-9]{1,2})/entry(/(.*))?/?$] => index.php?year=$matches[1]&monthnum=$matches[2]&entry=$matches[4]
    [([0-9]{4})/comment-page-([0-9]{1,})/?$] => index.php?year=$matches[1]&cpage=$matches[2]
    [([0-9]{4})/entry(/(.*))?/?$] => index.php?year=$matches[1]&entry=$matches[3]
    [.+?/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
    [.+?/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
    [.+?/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [.+?/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
    [.+?/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    [(.+?)/trackback/?$] => index.php?pagename=$matches[1]&tb=1
    [(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2]
    [(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?pagename=$matches[1]&feed=$matches[2]
    [(.+?)/page/?([0-9]{1,})/?$] => index.php?pagename=$matches[1]&paged=$matches[2]
    [(.+?)/comment-page-([0-9]{1,})/?$] => index.php?pagename=$matches[1]&cpage=$matches[2]
    [(.+?)(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2]
)

所以我看到平台和 Testtax 在那里,他们没有像我的自定义帖子类型重写的行多少,但是从我可以告诉它看起来像他们有规则应该使这项工作。

最佳解决方案

我找到这个代码

function ftc_flush_rewrites() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}

function ftc_add_rewrites() {
global $wp_rewrite;
$ftc_new_non_wp_rules = array(
'find/(this)' => '/addit.php?here=$1',
);

$wp_rewrite->non_wp_rules = $ftc_new_non_wp_rules + $wp_rewrite->non_wp_rules;
}

add_action('generate_rewrite_rules', 'ftc_add_rewrites');
add_action('admin_init', 'ftc_flush_rewrites');

在这个线程 http://wordpress.org/support/topic/writing-wp_rewrite-gtnon_wp_rules-to-htaccess … 不知道如果这是解决问题,但祝你好运!

次佳解决方案

/platform 页面不存在,因为 WordPress 不仅仅是根据您的 URL 结构创建一个页面。

如果需要在其中显示内容,可以创建一个名为”platform” 的”Page” 。

taxonomy-platform.php 是平台分类法中术语归档的默认模板。

taxonomy-platform-some_term.php 是一个特定术语的归档模板。

所有 WordPress 归档模板都用于术语归档。 WordPress 没有内置的方式将分类名称与帖子相关联,只有分类术语可以与帖子相关联。

分类名称=平台

  • some-platform(平台术语)

URL = http://some-domain.com/platform/some-platform

将使用 some-platform 分类术语列出所有帖子

可以删除”platform” 插槽前端,但不可能有分类归档页面:

http://some-domain.com/platform/

并获取所有具有与之关联的平台分类的帖子,而不创建具有自定义模板的平台页面进行必要的查询。

您的模板 taxonomy-platform.php 将用于任何平台术语归档页面。

第三种解决方案

尝试这个:

/**
* flush_rewrite_rules()
* Flush the rewrite rules, which forces the regeneration with new rules.
* return void.
**/
function flush_rewrite_rules()
{
    global $wp_rewrite;
    $wp_rewrite->flush_rules();
}

参考文献

注:本文内容整合自 Google/Baidu/Bing 辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:薇晓朵技术论坛。