2013-12-10 1 views
-1

WordPress 3.7.1에서 '게임'의 사용자 정의 게시 유형을 설정했습니다. 모든 것이 잘 작동하고 있으며,이 게시물 유형의 여러 항목을 작성하고 범주를 작성/할당했습니다. 이 CPT에서 게시물을 표시하는 쿼리는 정상적으로 작동하고 사용자 정의 단일 페이지 (single-game.php)도 작동합니다.Wordpress 사용자 정의 게시 유형 보관함로드 중

그러나 archive-game.php를 만들면 WordPress가 기본 archive.php 파일을로드하고 페이지 매김이 작동하지 않습니다. 저는 몇 시간 동안 수색을 해본 결과 몇 가지 해결책을 찾아 보았습니다. 이 CPT에서 작성한 각 범주의 아카이브를 얻으려고합니다. 제대로하고 있습니까? 이 문제에 영향을 미칠 수있는 최신 WordPress 버전이 변경 되었습니까?

public function gv_game_setup_post_types() { 
    $game_labels = array(
     'name'    => 'Games', 
     'singular_name'  => 'Game', 
     'add_new'    => __('Add New', 'game'), 
     'add_new_item'  => __('Add New Game', 'game'), 
     'edit_item'   => __('Edit Game', 'game'), 
     'new_item'   => __('New Game', 'game'), 
     'all_items'   => __('All Games', 'game'), 
     'view_item'   => __('View Game', 'game'), 
     'search_items'  => __('Search Games', 'game'), 
     'not_found'   => __('No Games found', 'game'), 
     'not_found_in_trash' => __('No Games found in Trash', 'game'), 
     'parent_item_colon' => '', 
     'menu_name'   => __('Games', 'game'), 
     'exclude_from_search' => false 
    ); 

    $game_args = array(
     'labels'    => $game_labels, 
     'public'    => true, 
     'has_archive'   => true, 
     'publicly_queryable' => true, 
     'show_ui'    => true, 
     'show_in_menu'  => true, 
     'query_var'   => true, 
     'capability_type'  => 'post', 
     'hierarchical'  => false, 
     'supports'   => array('editor', 'title', 'thumbnail', 'custom-fields'), 
     'taxonomies'   => array('category', 'post_tag'), 
     'rewrite'    => array('slug' => 'game', 'with_front' => false) 
    ); 

    register_post_type('game', $game_args); 
} 

이 기능은 내가이 목적을 위해 만든 사용자 정의 플러그인의 일부이며 '초기화하기'후크에 생성자에서 호출되는 :

다음은 사용자 정의 포스트 유형을 만들기위한 내 코드입니다.

도움을 주시면 감사하겠습니다.

감사합니다.

+0

는 "매김이 작동하지 않습니다"라고, 설명 슬러그 게임으로 기존 페이지가 없습니다 확인합니다. – Sinkingpoint

+0

매김입니다 돌아 오는 404 오류. – RyanPhil

답변

0

이 플러그인을 사용하여 사용자 정의 게시물 유형을 만들고, 일단 작동하면 함수 파일에 추가하는 PHP 코드를 내보내는 옵션이 있습니다. 그런 다음 플러그인을 비활성화합니다. 나에게 이것은 내가 일하도록하는 가장 안전한 방법이다. 물론 변경 사항을 적용한 후에는 관리자의 퍼머 링크 페이지를 방문해야합니다.

올바르게 사용자 정의 포스트 유형 아카이브 파일 아카이브-games.php를 만들 수 있습니다 그것을 작성하는 경우 http://wordpress.org/plugins/custom-post-type-ui/ (이것은 사용자 정의 포스트 유형 이름이됩니다, 예를 들어, 더 기능 파일에이 같은, 아카이브 페이지

add_action('init', 'cptui_register_my_cpt_game'); 
function cptui_register_my_cpt_game() { 
register_post_type('game', array(
'label' => 'Games', 
'description' => '', 
'public' => true, 
'show_ui' => true, 
'show_in_menu' => true, 
'capability_type' => 'post', 
'map_meta_cap' => true, 
'hierarchical' => false, 
'rewrite' => array('slug' => 'game', 'with_front' => true), 
'query_var' => true, 
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','post-formats'), 
'taxonomies' => array('category','post_tag'), 
'labels' => array (
'name' => 'Games', 
'singular_name' => '', 
'menu_name' => 'Games', 
'add_new' => 'Add Game', 
'add_new_item' => 'Add New Game', 
'edit' => 'Edit', 
'edit_item' => 'Edit Game', 
'new_item' => 'New Game', 
'view' => 'View Game', 
'view_item' => 'View Game', 
'search_items' => 'Search Game', 
'not_found' => 'No Game Found', 
'not_found_in_trash' => 'No Game Found in Trash', 
'parent' => 'Parent Game', 
) 
)); } 

물론 것은 당신이 그것을 작동하지 않는 방법