vtrotot/event-post-type

WordPress 主题的事件自定义文章类型

2.6.3 2023-07-07 10:00 UTC

README

EventPostType 是一个允许向 WordPress 主题添加自定义文章类型 vt_events 的包。
此自定义文章类型添加了三个元数据:开始日期、结束日期和地点。

VincentTrotot\Event\EventPostType 设置自定义文章类型。
VincentTrotot\Event\Event 是帖子的一种包装器(该类继承自类 Timber\TimberPost)。
VincentTrotot\Event\SportEvent 继承自类 VincentTrotot\Event\Event,在其中添加了用于处理具有季节性体育赛事的日历的方法。我们还可以向事件添加一个 club 类别,以表明事件是否面向会员。该类添加了一个 $outdated 属性,以确定事件是否已经在季节中过去了。

安装

composer require vtrotot/event-post-type

使用

您的主题必须实例化 EventPostType

new VincentTrotot\Event\EventPostType();

然后您可以获取一个事件类型的帖子

$post = new VincentTrotot\Event\Event();

或通过以下方式获取多个帖子

$args = [
    'post_type' => 'vt_event',
    ...
];
$posts = new Timber\TimberRequest($args, VincentTrotot\Event\Event::class);