Wordpress 永久链接/自定义帖子类型发布—;无法解决

Wordpress 永久链接/自定义帖子类型发布—;无法解决,wordpress,.htaccess,permalinks,Wordpress,.htaccess,Permalinks,我在网站上的一个自定义帖子类型现在不再有效:数据库条目仍然存在,但我无法访问帖子。我认为这是众所周知的permalinks问题,但在阅读了大量帖子并尝试了提供的解决方案后,我仍然无法解决这个问题 我有一个“single,php”文件,其中包含一些排序代码,然后重定向到三个不同的单个文件(“single-author.php”、“single-book.php”、“single-event.php”) 我尝试过的事情: 切换永久链接结构和切换回 刷新重写规则 正在检查.htaccess中的重写规

我在网站上的一个自定义帖子类型现在不再有效:数据库条目仍然存在,但我无法访问帖子。我认为这是众所周知的permalinks问题,但在阅读了大量帖子并尝试了提供的解决方案后,我仍然无法解决这个问题

我有一个“single,php”文件,其中包含一些排序代码,然后重定向到三个不同的单个文件(“single-author.php”、“single-book.php”、“single-event.php”)

我尝试过的事情:

  • 切换永久链接结构和切换回
  • 刷新重写规则
  • 正在检查.htaccess中的重写规则
如果我在这个自定义帖子类型中创建了一个新条目,我可以在“预览”中看到它,但一旦我发布它,我就会得到一个404。这个问题似乎没有影响我在网站上运行的其他自定义帖子类型。除了最近的WP更新,我还没有对网站做任何更改

我附上下面的相关代码-任何提示或帮助将不胜感激,因为我不知道还有什么可以尝试,以解决这个问题

非常感谢

add_action('init', 'authors_register');

function authors_register() {

$labels = array(
    'name' => _x('Authors', 'post type general name'),
    'singular_name' => _x('Author', 'post type singular name'),
    'add_new' => _x('Add New', 'portfolio item'),
    'add_new_item' => __('Add New Author'),
    'edit_item' => __('Edit Author'),
    'new_item' => __('New Author'),
    'view_item' => __('View Author'),
    'search_items' => __('Search Authors'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''
);

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 5,
    'supports' => array('title','thumbnail','revisions','excerpt'),
    'taxonomies' => array('category', 'post_tag')
  ); 

register_post_type( 'author' , $args ); 

}
single.php中的排序/切换代码:

<?php if ('post_type=book') { include (TEMPLATEPATH . '/single-book.php'); } 

elseif ('post_type=event') { include (TEMPLATEPATH . '/single-event.php'); } 

elseif ('post_type=author') { include (TEMPLATEPATH . '/single-author.php'); } 

else { include (TEMPLATEPATH . '/single-post.php'); } ?>


可能是作者姓名冲突。试着使用另一个post-type。谢谢Bindiya,尽管我不确定它会与什么冲突。我有一个页面列出了所有作者,但这是“page authors.php”(复数,所以是另一个slug)。谢谢@Eek–我已经替换了切换代码,但我担心问题仍然存在。你能详细说明最后一点吗?因为我不确定这意味着什么。谢谢有人能在这方面提供进一步的帮助吗?恐怕我还是有同样的问题。首先检查一下其他类型的帖子是否有效
single-$posttype.php
根据WordPress结构,默认情况下应该可以工作->如果不能工作,我们可以尝试到其他地方,如果可以工作,那么问题是您正在创建一个名为“author”的新帖子类型谢谢@Eek-单作者页面的模板文件名为'single author.php',但我仍然收到相同的错误。是的-我有两个其他自定义帖子类型('book'和'event'),它们都很好!
<?php if ('post_type=book') { include (TEMPLATEPATH . '/single-book.php'); } 

elseif ('post_type=event') { include (TEMPLATEPATH . '/single-event.php'); } 

elseif ('post_type=author') { include (TEMPLATEPATH . '/single-author.php'); } 

else { include (TEMPLATEPATH . '/single-post.php'); } ?>
<?php 
$post_type =  get_post_type();

if ( $post_type == 'book') { include (TEMPLATEPATH . '/single-book.php'); } 
elseif ($post_type == 'event') { include (TEMPLATEPATH . '/single-event.php'); } 
elseif ($post_type == 'author') { include (TEMPLATEPATH . '/single-author.php'); } 
else { include (TEMPLATEPATH . '/single-post.php'); } ?>
post
page
attachment
revision
nav_menu_item