2012-07-24 112 views
3

我創建了一個自定義後類型 - 新聞 - 使用的functions.php下面的代碼:該職位類型爲什麼我的自定義帖子類型帖子不顯示?

// Press Custom Post Type // 

function press_custom_init() { 

    $labels = array(
     'name' => _x('Press', 'post type general name'), 
     'singular_name' => _x('Press', 'post type singular name'), 
     'add_new' => _x('Add New', 'press'), 
     'add_new_item' => __('Add New Press Item'), 
     'edit_item' => __('Edit Item'), 
     'new_item' => __('New Press Item'), 
     'view_item' => __('View Press Item'), 
     'search_items' => __('Search Press'), 
     'not_found' => __('Nothing found'), 
     'not_found_in_trash' => __('Nothing found in Trash'), 
     'parent_item_colon' => '' 
    ); 

    $args = array(
     'labels' => $labels, 
     'public' => true, 
     'publicly_queryable' => true, 
     'show_ui' => true, 
     'show_in_menu' => true, 
     'show_in_nav_menus' => false, 
     'query_var' => true, 
     'rewrite' => array('slug','pages'), 
     'capability_type' => 'post', 
     'hierarchical' => false, 
     'menu_position' => 5, 
     'supports' => array('title','editor','thumbnail','excerpt',) 
    ); 

    register_post_type('press' , $args); 
} 
add_action('init', 'press_custom_init'); 

我已經加入項目,並新增了菜單項到我的導航欄,但是當我點擊鏈接,我收到'找不到帖子'的消息。

你可以在這裏看到:http://s13.mynewsitereview.com//press

請幫幫忙!

+1

您刷新了固定鏈接設置嗎? – fuxia 2012-07-24 06:05:59

回答

8

剛剛訪問在WP-admin的固定鏈接頁面http://yoursite.com/wp-admin/options-permalink.php來解決這個問題。

爲什麼?

建立在WordPress插件的任何(類型後,分類法,等。)之後,WordPress的需要更新/創建一組新的重寫規則(假設你使用漂亮的永久鏈接)。所有你需要做的是訪問你的後端永久鏈接頁面,這樣你可以生成新的規則爲您的新的職位類型,等等。技術術語是沖洗重寫規則(http://codex.wordpress.org/Function_Reference/flush_rewrite_rules)

相關問題