长话短说,我正在尝试让自定义帖子类型类别显示它显示‘项目-项’的位置,正如您看到的HERE
我认为这与我注册自定义post类型的方式有关,如下面的代码所示:
<?php
add_action( 'init', 'register_posts' );
function register_posts() {
register_post_type( 'team_post',
array(
'labels' => array(
'name' => __( "Team" ,"um_lang"),
'singular_name' => __( "Team" ,"um_lang")
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => "project_item", 'with_front' => TRUE),
'supports' => array('title','editor','thumbnail','page-attributes')
)
);
register_post_type( 'project_post',
array(
'labels' => array(
'name' => __( "Projects","um_lang"),
'singular_name' => __( "Project" ,"um_lang")
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => "project_item", 'with_front' => TRUE),
'supports' => array('title','editor','thumbnail','page-attributes')
)
);
register_taxonomy('project_category',array (
0 => 'project_post',
),array( 'hierarchical' => true, 'label' => __('Projects Category',"um_lang"),'show_ui' => true,'query_var' => true,'singular_label' => __('Projects Category',"um_lang")) );
}
?>发布于 2014-09-17 05:04:24
这会告诉wordpress将文本project_item插入到slug中,这就是正在发生的事情:
'rewrite' => array('slug' => "project_item", 'with_front' => TRUE)这意味着插入project_item的值:
'rewrite' => array('slug' => "%project_item%", 'with_front' => TRUE)发布于 2016-05-06 18:59:32
试试这个:
global $wp_rewrite;
$movies_structure = '/movies/%year%/%monthnum%/%day%/%movies%';
$wp_rewrite->add_rewrite_tag("%movies%", '([^/]+)', "movies=");
$wp_rewrite->add_permastruct('movies', $movies_structure, false);返回链接:
domain.com/movies/movie_name发布于 2014-09-18 03:25:24
我想通了。我安装了这个插件:https://wordpress.org/plugins/custom-post-type-permalinks/
然后,我没有使用%categories% (这不起作用),而是使用了特定的自定义帖子类型类别名称(它是%project_category%)
https://stackoverflow.com/questions/25875213
复制相似问题