在工具集类型插件上显示自定义帖子类型

时间:2017-08-02 11:07:36

标签: php wordpress plugins

我用php创建了一个自定义帖子类型,我的问题是这个帖子类型没有出现在Toolset Types Plugin的菜单中。我认为这必须是我必须填写的一些选项,但我已经尝试过几乎所有事情,我不知道为什么会发生这种情况。

我想编辑帖子类型之间的关系,特别是汽车和新闻之间的关系。

我创建自定义帖子类型的代码就是这个。

function car_post_type() {
    $labels = array(
        'name' => 'Coches',
        'singular_name' => 'Coche',
        'menu_name' => 'Coches',
        'name_admin_bar' => 'Coches',
        'parent_item_colon' => 'Padre:',
        'all_items' => 'Todos los coches',
        'add_new_item' => 'Añadir nuevo coche',
        'add_new' => 'Añadir coche',
        'new_item' => 'Nuevo coche',
        'edit_item' => 'Editar coche',
        'update_item' => 'Actualizar coche',
        'view_item' => 'Ver coche',
        'search_items' => 'Buscar coches',
        'not_found' => 'No hay resultados',
        'not_found_in_trash' => 'No se han encontrado coches en la papelera',
    );
    $rewrite = array(
        'slug' => 'coche',
        'with_front' => true,
        'pages' => true,
        'feeds' => true,
    );
    $args = array(
        'label' => __( 'Car', 'clever' ),
        'description' => __( 'Cars', 'clever' ),
        'labels' => $labels,
        'supports' => array(
            'title', 'editor', 'excerpt', 'thumbnail', 'revisions',
        ),
        'taxonomies' => array(),
        'hierarchical' => false,
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'menu_position' => 5,
        'menu_icon' => 'dashicons-dashboard',
        'show_in_admin_bar' => true,
        'show_in_nav_menus' => true,
        'can_export' => true,
        'has_archive' => true,
        'exclude_from_search' => false,
        'publicly_queryable' => true,
        'rewrite' => $rewrite,
        'capability_type' => 'post',
    );

    register_post_type('car', $args);
}
add_action('init', 'car_post_type', 0);

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

我找到了一个带有ACF插件的解决方案,这个插件允许在使用php创建其中一个帖子类型时在帖子类型之间创建关系。

您可以从此处下载插件:

https://www.advancedcustomfields.com/