首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >增加议程项目和通知

增加议程项目和通知
EN

WordPress Development用户
提问于 2017-02-09 15:03:34
回答 1查看 111关注 0票数 2

比方说,我正在为一个体育俱乐部创建一个网站。我想为教练和技术人员提供更多的旅游服务。

我想对这些数据做的是当然显示在巡回演出页面上。或者甚至可能在主页“即将到来的旅游:四月六日的巴布拉布拉旅游”的横幅上发布一份通知。

目前,我有一个简单的HTML表内的网站内容,文本编辑器的旅游页面。但对于没有HMTL知识的人来说,增加旅游并不容易。他们将不得不复制和粘贴它并编辑数据。太可怕了。

有人有办法解决我的问题吗?谢谢!

EN

回答 1

WordPress Development用户

回答已采纳

发布于 2017-02-16 00:35:45

WordPress的组织方式是为锦标赛、运动会和参与者创建单独的post类型。

下面是tournament post类型注册的一个示例:

代码语言:javascript
复制
add_action( 'wp_loaded', function() {

    register_post_type(
        'tournament',
        [
            'label' => __( 'Tournaments', 'tournaments' ),
            'labels' => [
                'name'                  => __( 'Tournaments', 'tournaments' ),
                'singular_name'         => __( 'Tournament', 'tournaments' ),
                'add_new'               => __( 'Add New', 'tournaments' ),
                'add_new_item'          => __( 'Add New Tournament', 'tournaments' ),
                'edit_item'             => __( 'Edit Tournament', 'tournaments' ),
                'new_item'              => __( 'New Tournament', 'tournaments' ),
                'view_item'             => __( 'View Tournament', 'tournaments' ),
                'view_items'            => __( 'View Tournaments', 'tournaments' ),
                'search_items'          => __( 'Search Tournaments', 'tournaments' ),
                'not_found'             => __( 'No tournaments found.', 'tournaments' ),
                'not_found_in_trash'    => __( 'No tournaments found in Trash.', 'tournaments' ),
                'parent_item_colon'     => __( 'Parent Tournament:', 'tournaments' ),
                'all_items'             => __( 'All Tournaments', 'tournaments' ),
                'archives'              => __( 'Tournament Archives', 'tournaments' ),
                'attributes'            => __( 'Tournament Attributes', 'tournaments' ),
                'insert_into_item'      => __( 'Insert into tournament', 'tournaments' ),
                'uploaded_to_this_item' => __( 'Uploaded to this tournament', 'tournaments' ),
                'featured_image'        => __( 'Banner', 'tournaments' ),
                'set_featured_image'    => __( 'Set banner', 'tournaments' ),
                'remove_featured_image' => __( 'Remove banner', 'tournaments' ),
                'use_featured_image'    => __( 'Use as banner', 'tournaments' ),
                'filter_items_list'     => __( 'Filter tournaments list', 'tournaments' ),
                'items_list_navigation' => __( 'Tournaments list navigation', 'tournaments' ),
                'items_list'            => __( 'Tournaments list', 'tournaments' ),
            ],
            'public' => TRUE,
            'hierarchical' =>TRUE,
            /*
             * 'edit_post' is now 'edit_tournament'
             * 'edit_posts' is now 'edit_tournaments'
             * Use these caabilities to set custom user capabilities, maybe
             * depending on the user role.
             */
            'capability_type' => [ 'tournament', 'tournaments' ],
            'map_meta_cap' => TRUE,
            'supports' => [
                'title',
                'editor',
                'comments',
                'revisions',
                'author',
                'excerpt',
                'page-attributes', // allows multiple custom tournament templates
                'thumbnail',
                'custom-fields'
            ],
            'has_archive' => __( 'tournaments', 'tournaments' ),
            'rewrite' => [
                'slug' => __( 'tournament', 'tournaments' ),
            ],
            'delete_with_user' => FALSE,
        ]
    );
});

正如您所看到的,您可以为该帖子类型使用一些内置功能,比如横幅的特征图像。您还可以将此post类型分层为具有“父”页的经常性比赛,并为每年或每个月的实例单独的页面。

我现在还将以类似的方式设置gamesplayers post类型(当然不是分层的)。然后,我会注册一个自定义用户角色的人,谁可以添加或编辑比赛。

对于概述页面,请使用归档模板,在本例中为archive-tournament.php。有关更多信息,请参见模板层次。与通常的帖子列表不同,您可以轻松地在这里构建一个表。在每个锦标赛页面(single-tournament.php)上,您可以列出游戏和玩家、开始和结束时间、价格等等。对于这些数据,请在“锦标赛编辑器”页面上使用自定义元框。

这只是一个原始的概念。实际实施将需要一段时间。确保手动编写代码,不要使用“神奇”post类型的UI插件!原因是,您很可能需要随着时间的推移对这段代码进行修改;您应该彻底了解每一行。

票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/255827

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档