Tôi có một danh mục trên trang web của mình được gọi là 'hồ sơ' Tôi đang trong quá trình chuyển danh mục này sang loại bài đăng tùy chỉnh được gọi là 'hồ sơ'.
Vấn đề của tôi là tôi không thể có được trang lưu trữ để hiển thị cho loại bài đăng tùy chỉnh này. Khi tôi đi tới url, mywebsite.com/profiles
nó sẽ đưa tôi đến một trang bài đăng cho một bài đăng trong danh mục hồ sơ.
Tôi đã bao gồm has_archive = true;
trongfunctions.php
Tôi không gặp vấn đề gì khi tạo trang lưu trữ cho một loại bài đăng tùy chỉnh khác mà tôi đã làm trên cùng một trang web vì vậy tôi thực sự bị mất lý do tại sao điều này không hoạt động trong thời gian này.
Bất kì lời khuyên nào cũng có thể được đánh giá cao?
add_action( 'init', 'profile_custom_init' );
/* Here's how to create your customized labels */
function profile_custom_init() {
$labels = array(
'name' => _x( 'Profiles', 'post type general name' ), // Tip: _x('') is used for localization
'singular_name' => _x( 'Profile', 'post type singular name' ),
'add_new' => _x( 'Add New', 'Profile' ),
'add_new_item' => __( 'Add Profile' ),
'edit_item' => __( 'Edit Profile' ),
'new_item' => __( 'New Profile' ),
'view_item' => __( 'View Profile' ),
'search_items' => __( 'Search Profile' ),
'not_found' => __( 'No Profile found' ),
'not_found_in_trash' => __( 'No Profile found in Trash' ),
'parent_item_colon' => ''
);
// Create an array for the $args
$args = array( 'labels' => $labels, /* NOTICE: the $labels variable is used here... */
'public' => true,
'publicly_queryable' => true,
'has_archive' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 10,
'supports' => array( 'title', 'editor','thumbnail', 'excerpt', 'custom-fields' ),
'taxonomies' => array('category')
);
register_post_type( 'profile', $args ); /* Register it and move on */
}