CPT不在导航菜单内显示

时间:2020-01-20 作者:sialfa

我创建了一个cpt来实现网站的一个专用部分,我想在导航栏中显示它,并在儿童时期链接在cpt下创建的各种帖子。我注意到我注册的cpt无法识别,但我注册的另外两个cpt显示在menùeditor中,我可以选择它们。有解决方案吗?

  /*
  * Post type: Services
  */

  function services()
  {
    $labels = array(
      \'name\'               => _x( \'Servizi\', \'post type general name\'),
      \'singular_name\'      => _x( \'Servizi\', \'post type singular name\'),
      \'menu_name\'          => _x( \'Servizi\', \'admin menu\'),
      \'name_admin_bar\'     => _x( \'Servizi\', \'add new on admin bar\'),
      \'add_new\'            => _x( \'Aggiungi Servizi\', \'Aggiungi servizio\'),
      \'add_new_item\'       => __( \'Aggiungi Servizi\'),
      \'new_item\'           => __( \'Aggiungi Servizi\'),
      \'edit_item\'          => __( \'Modifica Servizi\'),
      \'view_item\'          => __( \'Visualizza Servizi\'),
      \'all_items\'          => __( \'Visualizza Tutto\'),
      \'featured_image\'     => __( \'Featured Image\', \'text_domain\' ),
      \'search_items\'       => __( \'Cerca Servizio\'),
      \'parent_item_colon\'  => __( \'Parent:\'),
      \'not_found\'          => __( \'No service found.\'),
      \'not_found_in_trash\' => __( \'No service found in Trash.\'),
    );

    $args = array(
      \'labels\'             => $labels,
      #\'menu_icon\'       => \'dashicons-star-half\',
     \'description\'        => __( \'Description.\'),
      \'public\'             => true,
      \'publicly_queryable\' => true,
      \'show_ui\'            => true,
      \'show_in_menu\'       => true,
      \'query_var\'          => true,
      \'rewrite\'            => true,
      \'capability_type\'    => \'post\',
      \'has_archive\'        => true,
      \'hierarchical\'       => true,
      \'menu_position\'      => null,
      \'supports\'           => array(\'title\',\'editor\',\'thumbnail\',\'custom-fields\',\'excerpt\')
    );

    register_post_type( \'services\', $args );
  }
  add_action(\'init\', \'services\');
我用于其他两个cpt的代码是相同的。

1 个回复
最合适的回答,由SO网友:Vitauts Stočka 整理而成

选中菜单编辑器窗口中的屏幕选项,您应该选中您的cpt框。