0
0

More than 3 years have passed since last update.

WPプラグイン「Event Organiser」でイベント開催日を取得する

Last updated at Posted at 2020-01-20

Event Oraniser

イベントカレンダーを作れるWordpress公式プラグイン。
https://ja.wordpress.org/plugins/event-organiser/

ただ、デフォルトだと日付の表示が1月 2020年とか25-01-2020になってるので馴染みのある形式にフォーマットして取得します。

日付の表示を修正

まずはプラグインを検索して有効化します。
スクリーンショット 2020-01-20 16.34.31.png

修正するファイルは下記
/wp-content/plugins/event-organiser/includes/event-organiser-event-functions.php

1384行目くらい
'titleformatmonth' => 'F Y年'

'titleformatmonth' => 'Y年 F'

イベント日の取得方法

それぞれの日付は下記の関数で取得します。

開始日:eo_get_schedule_start()
終了日:eo_get_the_end()

eo_get_schedule_last()というのもあるらしく引っかかりました。。。

パラメータに応じてフォーマットしてくれます。
event-organiser-event-functions.phpをイジるよりこのほうが良さそうですね。

<?php echo eo_get_schedule_start('Y年n月j日'); ?>
2020年1月21日

Googleカレンダーっぽい感じで使えそうなところが ◯

イベントカレンダー作るときはお世話になりそうなプラグインですが
毎回「これどうやるんだっけ?」ってなりそうなので備忘として残しておきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0