无法获取要显示的自定义模板分类页面

时间:2011-04-27 作者:Sam K

我一直在努力学习分类法的来龙去脉,以及如何将它们整合到主题中,但我遇到了一个我似乎无法理解的非常基本的问题。

我开始在BuddyPress安装中使用更多分类法来处理这个问题。在无法使用平台的重写slug获取要加载的自定义模板(taxonomy platform.php)之后。。。www.mydomain。com/wpinstall/platform。。。。我删除了更多分类法中的分类法(但不是术语数据库中的条目),卸载了更多分类法,并将分类法输入到我的buddypress函数中。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\' ),
  ));
}
但这仍然不允许它正常工作。

*这里我要指出的是,在整个过程中,我一直过分热衷于使用Permalinks页面保存方法刷新重写。

然后我回到2010年,并在函数中输入相同的代码。php,然后重试,结果相同。分类法显示在所有帖子类型下,它从数据库中提取旧术语数据,正确输入帖子,但我无法打开分类法平台。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\' ),
        ));

 }
这出现了(虽然它在我的帖子类型中被称为第二个“帖子标签”,但我想这是因为我减少了这么多标签),但在尝试导航到www.mydomain时显示了相同的行为。com/wpinstall/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(); ?>
同样,目前尽可能简单,但我也使用了索引和其他各种启用循环的页面的副本。

任何帮助都将不胜感激,提前感谢!不确定我是否遗漏了一些简单的东西,或者跳过了正确启用分类法的过程。。。只是不确定。




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

我看到过一些关于此类问题的帖子,我注意到一些人能够从WordPress中刷新他们的整个软重写规则。我想我会看看自己是否能得到同样的打印结果。首先我补充道;

add_action(\'wp_footer\', \'show_rewrite_rules\');
function show_rewrite_rules(){
  global $wp_rewrite;
  echo "<pre>";
  print_r($wp_rewrite->rules);
  echo "</pre>";
}
因此,将其添加到我的函数中。2010年的php(我基本上保持了我的2010主题和BuddyPress安装/主题的最新状态,包括所有这些可能的修复、更改和测试-还多次禁用插件并进行了保存,因为我尝试了下面的一些建议)。我得到了这个输出;

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]
)
所以我在这里看到了Platform和Testtax,它们的行数没有我的自定义帖子类型的重写那么多,但是从我所能看到的来看,它们确实有一些规则可以让这项工作正常进行。

4 个回复
最合适的回答,由SO网友:Keith Comito 整理而成

我找到了这个代码;

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 ...不确定这是否解决了问题,但祝你好运!

SO网友:Chris_O

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

您可以创建一个;第“”页;称为;“平台”;如果您需要在那里显示内容。

分类平台。php是的默认模板term archives 在平台分类中。

taxonomy-platform-some\\u术语。php是一个特定术语的归档模板。

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

分类名称=平台

  • 某些平台(平台术语)
    • URL=http://some-domain.com/platform/some-platform

      将列出所有带有某个平台分类术语的帖子

      可以删除;“平台”;slug front,但不可能有以下分类法归档页:

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

      并将所有与平台分类法关联的帖子存档,而无需创建带有自定义模板的平台页面来进行必要的查询。

      模板分类平台。php将用于任何平台term 归档页面。

SO网友:kaiser

Try this one:

/**
* 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();
}
SO网友:Sid-just-Sid

以防万一,有人在这段时间后(2011年)读到了这篇文章:我遇到了同一个问题,在读了许多帖子后,回到我的WP,然后‘瞧!’:它按预期工作!这是缓存问题IMHO(WP 4.2.2)。

干杯

结束

相关推荐

Can't get permalinks working!

我无法让WordPress pretty permalinks在我的Fedora LAMP服务器上工作。如果我设置它们并单击页面/帖子链接,我会得到一个“哎呀!此链接似乎已断开。“”这个。htaccess文件可写且正在更新,mod\\u重写模块似乎已加载到我的httpd中。conf(见下文)我的apache日志中的错误只是说“找不到文档”</我已经筋疲力尽了!这是httpd.conf:### Section 1: Global Environment # start the rew