2013-12-10 73 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代碼,然後將其添加到函數文件中,然後禁用該插件。對我來說,這是確保我工作的最安全的方式。當然,在做任何改變之後,你總是應該訪問管理員的永久鏈接頁面。

http://wordpress.org/plugins/custom-post-type-ui/

如果你創建正確,您可以創建自定義類型後歸檔文件歸檔games.php(這將是你的自定義後類型名稱,例如,更多的東西像這樣在你的函數文件,

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', 
) 
)); } 

當然,確保你沒有與蛞蝓遊戲的任何現有網頁

相關問題