1

이제이 내용이 상당히 많이 다루어 졌음을 알고 있습니다.하지만 여기에 이전 수정 사항을 읽었으며 행운이 없었습니다.사용자 정의 포스트 유형 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); 

} 
+0

모든 유형의 "예쁜 퍼머 링크"가 작동합니까, 아니면 CPT 관련 문제입니까? 예쁜 퍼머 링크가 모두 깨진 경우 Apache 구성에서'mod_rewrite'를 활성화해야합니다. – Ennui

+0

또한'$ args'에서'rewrite' 매개 변수를 제거하면됩니다 (기본값은 true로 설정하고 게시물 유형 slug'question'을 재 작성에 사용합니다). – Ennui

+0

답장을 보내 주셔서 감사합니다. 다른 모든 퍼머 링크는 작동하지 않습니다. 내가 재 작성 perameter를 제거하고 어떤 차이가 있는지 확인하려고합니다. – Mark

답변

5

3 일 후에 나는 => 진정한 나에게 오류를 제공 '계층'입니다 발견했다.

이 코드 줄을 제거한 다음 영구 링크를 기본값으로 설정하여 영구 링크를 새로 고치면 곧 다시 문제가 변경되는 문제가 해결되었습니다.

+0

내가 계층 적 게시물 유형이 있고 그것을 제거 할 수 없다면 어떻게해야합니까 ?? –

2

실제에서는 새로운 맞춤 게시물을 만든 후 영구 링크를 업데이트해야합니다 ('hierarchical' => 'true'). 404 오류에는 영향을 미치지 않습니다. 그냥 permalinks에 가서 다시 저장 그것을 흐름에했다.

+0

제안 해 주셔서 감사하지만 당시 새 고객 게시판을 만든 후 영구 링크를 업데이트했습니다. 이것은 어떤 차이도 없었고이 오류를 해결할 수있는 유일한 방법은 'hierarchical'=> true를 제거하는 것이 었습니다. – Mark

관련 문제