【问题标题】:Why isnt my custom post type not showing on the frontend navigation menu为什么我的自定义帖子类型没有显示在前端导航菜单上
【发布时间】:2016-06-23 01:22:38
【问题描述】:

我创建了一个自定义帖子类型,它显示在后端... {外观 > 菜单}

当我将它添加到我的导航菜单列表时,它不会显示在前端。我真的很困惑为什么它不显示。我仔细检查了 register_post_type 的标签和参数,它们似乎都是正确的。

下面是我的代码。任何帮助将不胜感激!

<?php


function mtl_register_todo(){

    $singular_name = apply_filters("mtl_label_single","Todo");
    $plural_name = apply_filters("mtl_label_single","Todos");


    $labels = [

        "name"=> $plural_name,
        "singular_name"=> $singular_name,
        "add_new"       => "Add new",
        "add_new_item"  => "Add new ". $singular_name,
        "edit"          => "Edit",
         "edit_item"    => "Edit ". $singular_name,
        "new_item"      => "New ". $singular_name,
        "view"          => "View",
        "view_item"     => "View " . $plural_name,
        "search_items"  => "Search ". $plural_name,
        "not_found"     => "No ". $plural_name . " found",
        "not_found_in_trash" => "",
        "menu_name"         => $plural_name


    ];


    $args = apply_filters("mtl_todo_args",[

        "labels"        =>$labels,
        "description"   => "Todo's categories",
        "taxonomies"    => ["category"],
        "public"        => TRUE,
        "show_in_menu" => TRUE,
        "position"      => 5,
        "menu_icon"    =>"dashicons-edit",
        "show_in_nav_menus" => TRUE,
        "query_var"=> TRUE,
        "can_export"    => true,
        "rewrite"    => ["slug"=>"todo"],
        "capability_type"  => "post",
        "supports"   =>  [

            "title"


        ]



    ]);


    //Register post type

    register_post_type("todo",$args);


}

add_action("init","mtl_register_todo");

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    确保您设置了以下数组条目:

    'show_ui'               => true,
    'show_in_menu'          => true,
    'show_in_admin_bar'     => true,
    'show_in_nav_menus'     => true,
    

    【讨论】:

      猜你喜欢
      • 2013-10-21
      • 2012-07-22
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 1970-01-01
      • 2019-09-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多