我遇到了在前端重写自定义帖子类型的永久链接网址的问题。如果我设置自定义帖子类型的“重写”选项它开始工作,但网址是旧式查询字符串。
我查了很多论坛,但没有解决我的问题。帖子类型选项是
$options = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
//'rewrite' => array('slug' => $name, 'with_front' => true),
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => NULL,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);
问题的根本原因可能是我添加的重写规则。我也希望包含这些规则,并希望在前端显示自定义帖子类型,正确导致404。
add_rewrite_tag('%edit%','([^&]+)');
add_rewrite_rule('^edit/([^/]*)/([^/]*)/?','index.php?page_id='.$page_id.'&table=$matches[1]&id=$matches[2]&process=edit','top');
add_rewrite_tag('%view%','([^&]+)');
add_rewrite_rule('^view/([^/]*)/?','index.php?page_id='.$page_id.'&table=$matches[1]&id=$matches[2]','top');
add_rewrite_tag('%delete%','([^&]+)');
add_rewrite_rule('^delete/([^/]*)/([^/]*)/?','index.php?page_id='.$page_id.'&table=$matches[1]&id=$matches[2]&process=delete','top');
add_rewrite_tag('%show%','([^&]+)');
add_rewrite_rule('^show/([^/]*)/([^/]*)/?','index.php?page_id='.$page_id.'&table=$matches[1]&id=$matches[2]&process=delete','top');
add_rewrite_tag('%coach%','([^&]+)');
add_rewrite_rule('^coach/([^/]*)/?','index.php?page_id='.$page_id.'&id=$matches[1]','top');
add_rewrite_tag('%athlete%','([^&]+)');
add_rewrite_rule('^athlete/([^/]*)/?','index.php?page_id='.$page_id.'&id=$matches[1]','top');
flush_rewrite_rules();
请帮帮我。
答案 0 :(得分:0)
请确保您没有任何缓存插件阻碍您。
尝试删除.htaccess文件 但是不要备份它!