奇怪的是,我在网上找不到多少关于我的欲望的消息来源。所以我希望这是一件小事(尽管我担心不是,Wordpress只是……)。
当然,我的自定义帖子类型中需要自定义字段。
Wordpress处理自定义字段的原生方式非常不方便,我不能期望我的客户处理这些下拉列表,根据需要添加字段——
到目前为止,我使用“高级自定义字段”插件管理我的自定义字段。
我想了解如何自己做到这一点,因此希望在定制“新帖子”和“编辑帖子”页面的工作区/管理区方面有更多的灵活性。
必须有一种方法来设置代码中的自定义字段,并影响如何在管理页面上访问输入。
举一个简单的例子,我想在页面中添加一个快速链接功能,管理员可以添加只包含标题和url的帖子(我知道本地的“链接”区域,并有意避免使用它)
到目前为止,我制作了一个简单的单文件插件,其中包含自定义帖子类型的声明:
<?php
/*
Plugin Name: Got Nexxt Quicklinks
Plugin URI: none
Description: Quicklinks custom post type + special admin area
Author: René Eschke
Version: 1.0
Author URI: http://www.eschke.info/
*/
function my_custom_post_quicklinks() {
$labels = array(
\'name\' => _x( \'Quicklinks\', \'post type general name\' ),
\'singular_name\' => _x( \'Quicklink\', \'post type singular name\' ),
\'add_new\' => _x( \'Hinzufügen\', \'book\' ),
\'add_new_item\' => __( \'Quicklink hinzufügen\' ),
\'edit_item\' => __( \'Quicklink bearbeiten\' ),
\'new_item\' => __( \'Neue Quicklink\' ),
\'all_items\' => __( \'Alle Quicklinks\' ),
\'view_item\' => __( \'Quicklink ansehen\' ),
\'search_items\' => __( \'Quicklink durchsuchen\' ),
\'not_found\' => __( \'Kein Quicklink gefunden\' ),
\'not_found_in_trash\' => __( \'Keine Quicklinks im Papierkorb gefunden\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Quicklinks\'
);
$args = array(
\'labels\' => $labels,
\'menu_icon\' => \'dashicons-admin-links\',
\'description\' => \'Quicklinks sind vor allem für Shortcuts zu bestimmten Podcast-positionen da\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => array(\'title\'),
\'has_archive\' => false,
);
register_post_type(\'quicklink\', $args);
}
add_action( \'init\', \'my_custom_post_quicklinks\' );
?>
再次强调:I want to implement this myself all in code without using a plugin.谢谢