您需要在插件文件中添加自定义帖子类型,如下所示
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
register_post_type(\'file\', array(
\'label\' => __(\'Organizations\'), // e.g. apples
\'singular_label\' => __(\'Organization\'), // e.g. apple
\'public\' => true,
\'show_ui\' => true, // UI in admin panel
\'_builtin\' => false, // It\'s a custom post type, not built in!
\'_edit_link\' => \'post.php?post=%d\',
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => array("slug" => "YOURNAME"), // Permalinks format
\'supports\' => array(\'title\',\'author\',\'custom-fields\',\'comments\' )
));
}
有关完整的可能选项,请参阅本页register post type
然后,要将每个字段添加到post类型,可以使用post meta。
add_post_meta($post_id, YOURMETANAME, YOURVALUE);
add_post_meta($post_id, \'Name\', \'John Doe\');
您可以通过以下方式检索:
get_post_meta($post_id, YOURMETANAME, YOURVALUE);
get_post_meta($post_id, \'Name\', \'John Doe\');
这不能用简单的复制/粘贴来完成,它将需要您方面的一些工作。。。