이제이 내용이 상당히 많이 다루어 졌음을 알고 있습니다.하지만 여기에 이전 수정 사항을 읽었으며 행운이 없었습니다.사용자 정의 포스트 유형 404
기본적으로 질문을위한 내 맞춤 게시물 유형이 404 오류를 제공합니다.
- 기본값으로 영구 링크를 설정 한 다음 다시 다시 변경 :
지금까지 나는 다음 시도했습니다.
- register_post_type 바로 앞에 flush_rewrite_rules를 추가하십시오.
- 같은 이름의 페이지와 게시물이 있는지 확인했습니다.
- htaccess 파일을 삭제하고 다시 작성했습니다.
- 사용자 정의 퍼머 링크 구조를 만드는 'rewrite'=> array ('slug'=> 'question', 'with_front'=> FALSE)
코드는 다음과 같습니다 :이 문제를 해결하기 위해 노력
add_action('init', 'irt_questions_create');
function irt_questions_create() {
$labels = array(
'name' => _x('Questions', 'post type general name', 'your_text_domain'),
'singular_name' => _x('Question', 'post type singular name', 'your_text_domain'),
'add_new' => _x('Add New', 'Question', 'your_text_domain'),
'add_new_item' => __('Add New Question', 'your_text_domain'),
'edit_item' => __('Edit Question', 'your_text_domain'),
'new_item' => __('New Question', 'your_text_domain'),
'all_items' => __('All Questions', 'your_text_domain'),
'view_item' => __('View Question', 'your_text_domain'),
'search_items' => __('Search Questions', 'your_text_domain'),
'not_found' => __('No Questions found', 'your_text_domain'),
'not_found_in_trash' => __('No Questions found in Trash', 'your_text_domain'),
'parent_item_colon' => '',
'menu_name' => __('Questions', 'your_text_domain')
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => _x('module', 'URL slug', 'your_text_domain')),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => 106,
'supports' => array('title', 'editor', /*'author',*/ 'thumbnail', /*'excerpt', 'comments', 'custom-fields', 'revisions',*/ 'page-attributes')
);
register_post_type('question', $args);
}
모든 유형의 "예쁜 퍼머 링크"가 작동합니까, 아니면 CPT 관련 문제입니까? 예쁜 퍼머 링크가 모두 깨진 경우 Apache 구성에서'mod_rewrite'를 활성화해야합니다. – Ennui
또한'$ args'에서'rewrite' 매개 변수를 제거하면됩니다 (기본값은 true로 설정하고 게시물 유형 slug'question'을 재 작성에 사용합니다). – Ennui
답장을 보내 주셔서 감사합니다. 다른 모든 퍼머 링크는 작동하지 않습니다. 내가 재 작성 perameter를 제거하고 어떤 차이가 있는지 확인하려고합니다. – Mark