Я настроил пользовательский тип записи, который называется проектами.Когда проект просматривается, это URL-адрес, на котором он включен: http://example.com/blog/projects/project-number-one Но я хочу, чтобы он отображался без / blog следующим образом: http://example.com/projects/project-number-one
Моя структура постоянных ссылок: / blog /% postname% /
Если я удаляю / blog из структуры постоянной ссылки, тогда URL-адреса проекта верны: http://example.com/projects/project-number-one
Но тогда мои посты выглядят так (без out / blog): http://example.com/blog-post
То, на что я намотал, - это то, как ULR моих постов в блоге будет выглядеть так: http://example.com/blog/blog-post И мои проекты будут такими: http://example.com/projects/project-number-one
// This is my custom post type code:
function custom_post_type_projects() {
$labels = array(
'name' => 'Projects',
'singular_name' => 'Project',
'menu_name' => 'Projects',
'name_admin_bar' => 'Projects',
'archives' => 'Projects',
'attributes' => 'Projects Attributes',
'parent_item_colon' => 'Parent Project:',
'all_items' => 'All Project pages',
'add_new_item' => 'Add New Project / Project Page',
'add_new' => 'Add New',
'new_item' => 'New Project / Project Page',
'edit_item' => 'Edit Project / Project Page',
'update_item' => 'Update Project / Project Page',
'view_item' => 'View Project / Project Page',
'view_items' => 'View Projects',
'search_items' => 'Search Project / Project Pages',
'not_found' => 'Not found',
'not_found_in_trash' => 'Not found in Trash',
'featured_image' => 'Featured Image',
'set_featured_image' => 'Set featured image',
'remove_featured_image' => 'Remove featured image',
'use_featured_image' => 'Use as featured image',
'insert_into_item' => 'Insert into Project page',
'uploaded_to_this_item' => 'Uploaded to this item',
'items_list' => 'Projects list',
'items_list_navigation' => 'Projects list navigation',
'filter_items_list' => 'Filter Projects list',
);
$args = array(
'label' => 'Project',
'description' => 'Projects',
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'revisions', 'excerpt'),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-format-gallery',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'projects',
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
'show_in_rest' => true
);
register_post_type( 'projects', $args );
}
add_action( 'init', 'custom_post_type_projects', 0 );