2016-12-24 83 views
0

我試圖在WordPress中創建自定義帖子。我按照下面的代碼註冊帖子。代碼正在運行。但菜單不顯示在Dashedboard中。Wordpress自定義帖子未顯示在Dashedboard中

<?php 
function app_theme_custom_posts() { 
    register_post_type('prime', array(
    'label' => 'Prime', 
    'labels' => array(
     'name' => 'Primes', 
     'singular_name' => 'Prime', 
     ), 
     'public' => 'true', 
     'menu_icon' => 'dashicons-images-alt', 
     'supports' => array('title', 'editor', 'thumbnail','custom-fields'), 
     )); 
} 
add_action('init','app_theme_custom_posts'); 

?> 

回答

0

嘗試這個 -

<?php 
function app_theme_custom_posts() { 
    register_post_type('prime', array(
    'labels' => array(
      'name' => __('Primes'), 
      'singular_name' => __('Prime'), 
      'add_new' => __('New Prime)' 
     ), 
     'public' => true, 
     'has_archive' => false, 
     'menu_icon' => 'dashicons-images-alt', 
     'supports' => array('title', 'editor', 'thumbnail','custom-fields'), 
     )); 
} 
add_action('init','app_theme_custom_posts'); 

?> 
+0

感謝重新編寫代碼。但顯示第13行的分析錯誤 – Hasan

+0

我現在唯一能想到的就是將has_archive更改爲true,因爲這是唯一不同於我工作代碼的行。如果你使用has_archive = true,那麼你需要在它後面添加''rewrite'=> array('slug'=>'book'), –

相關問題