我创建了一个名为Products byside by blog的自定义帖子类型。我的博客存档网址
/opt/kubernetes/addons/skydns-svc.yaml": error validating data: found invalid field portalIP for v1.ServiceSpec; if you choose to ignore these errors, turn validation off with --validate=false
并且博客文章看起来像
www.mywebsite.com/blog
我的产品自定义帖子类型网址如
www.mywebsite.com/blog/postName.
我想从网址中删除博客目录并使其看起来像
www.mywebsite.com/blog/products.
我可以通过从Wordpress中的永久链接中删除www.mywebsite.com/products/productName
来执行此操作,但之后我的博客文章如下:/blog/%postname%
,没有博客目录。
如何在没有博客目录的情况下为自定义帖子类型提供干净的网址?
答案 0 :(得分:0)
也许它可以帮到你。做那样的事情 -
$labels = array(
'name' => $plural_title,
'singular_name' => $title,
'add_new' => __( 'Add New', 'adeq' ),
'add_new_item' => __( 'Add New', 'adeq' ) .' '. $title,
'edit_item' => __( 'Edit', 'adeq' ) .' '. $title,
'new_item' => __( 'New', 'adeq' ) .' '. $title,
'all_items' => __( 'All', 'adeq' ) .' '. $plural_title,
'view_item' => __( 'View', 'adeq' ) .' '. $title,
'search_items' => __( 'Search', 'adeq' ) .' '. $plural_title,
'not_found' => $plural_title . __( ' not found', 'adeq' ),
'not_found_in_trash' => $plural_title . __( ' not found in Trash', 'adeq' ),
'parent_item_colon' => '',
'menu_name' => $plural_title
);
if ( !empty( $args['labels_override'] ) ) {
$labels = wp_parse_args( $args['labels_override'], $labels );
}
$defaults = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'menu_icon' => null,
'supports' => array( 'title', 'thumbnail', 'editor' )
);
$args = wp_parse_args( $args, $defaults );
$this->post_types[ $post_type ] = $args;
}
}