在菜单中添加自定义帖子类型链接的自定义分类时获取(无效)

时间:2013-06-12 作者:Radolino

当我尝试向菜单添加链接时,收到以下消息:

screenshot

我已经创建了自定义帖子类型和自定义分类法

<?php
   /*
   Plugin Name: Portfolio - Custom Post Type
   Plugin URI: 
   Description: 
   Version: 1.0
   Author:
   Author URI: 
   License:
   */
?>
<?php

// ----- Register custom post type ------ //

add_action( \'init\', \'create_post_type_portfolio\' );

function create_post_type_portfolio() {
    $labels = array(
        \'name\'               => _x( \'Portfolios\', \'post type general name\' ),
        \'singular_name\'      => _x( \'Portfolio\', \'post type singular name\' ),
        \'add_new\'            => _x( \'Add New\', \'job\' ),
        \'add_new_item\'       => __( \'Add New Portfolio item\' ),
        \'edit_item\'          => __( \'Edit Portfolio Item\' ),
        \'new_item\'           => __( \'New Portfolio Item\' ),
        \'all_items\'          => __( \'All Portfolio Items\' ),
        \'view_item\'          => __( \'View Portfolio Item\' ),
        \'search_items\'       => __( \'Search Portfolio Items\' ),
        \'not_found\'          => __( \'No Portfolio Items found\' ),
        \'not_found_in_trash\' => __( \'No Portfolio Items found in the Trash\' ), 
        \'parent_item_colon\'  => \'\',
        \'menu_name\'          => \'Portfolio Items\'
    );
    $args = array(
        \'labels\'        => $labels,
        \'description\'   => \'Holds our Portfolio Items and Portfolio Item specific data\',
        \'public\'        => true,
        \'menu_position\' => 5,
        \'menu_icon\'     => plugins_url( \'portfolio.png\', __FILE__ ),
        \'supports\'      => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\', \'comments\' ),
        \'has_archive\'   => true,
        \'show_in_nav_menus\' => true,
        \'rewrite\'       => true,
        \'show_ui\'       => true,

    );
    register_post_type( \'portfolio\', $args );   
}

// ------------- register taxonomy ----------------- //

// hook into the init action and call create_portfolio_taxonomies when it fires
add_action( \'init\', \'create_portfolio_taxonomies\', 0 );

// create Work for the post type "portfolio"
function create_portfolio_taxonomies() {
    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
        \'name\'              => _x( \'Work\', \'taxonomy general name\' ),
        \'singular_name\'     => _x( \'Work\', \'taxonomy singular name\' ),
        \'search_items\'      => __( \'Search Work\' ),
        \'all_items\'         => __( \'All Work\' ),
        \'parent_item\'       => __( \'Parent Work\' ),
        \'parent_item_colon\' => __( \'Parent Work:\' ),
        \'edit_item\'         => __( \'Edit Work\' ),
        \'update_item\'       => __( \'Update Work\' ),
        \'add_new_item\'      => __( \'Add New Work\' ),
        \'new_item_name\'     => __( \'New Work Name\' ),
        \'menu_name\'         => __( \'Work\' ),
    );

    $args = array(
        \'hierarchical\'      => true,
        \'labels\'            => $labels,
        \'show_ui\'           => true,
        \'show_admin_column\' => true,
        \'query_var\'         => true,
        \'show_in_nav_menus\' => true,
        \'rewrite\'           => array( \'slug\' => \'work\' )
    );

    register_taxonomy( \'Work\', array( \'portfolio\' ), $args );
}



?>
为什么?

1 个回复
最合适的回答,由SO网友:Radolino 整理而成

我已经将我的插件文件复制到一个新的插件文件中。php文件并停用旧文件/激活新文件。然后一切都成功了。我需要提到的是,我将分类法的名称从“Kind”改为“Stuff”,所以我想数据库中可能有错误或其他东西。

结束

相关推荐

Custom menus not showing

作为我上一次关于菜单的未解决查询的后续,这个问题已经进一步扩展。我的菜单没有打印代码中的任何地方。我正在注册菜单功能。php:add_action( \'after_setup_theme\', \'your_newtheme_setup\' ); if ( ! function_exists( \'your_newtheme_setup\' ) ) : function your_newtheme_setup() { if (