月末を期限としたキャンペーンで、毎月期限を延ばすという謎仕様の依頼があったので、以下の様なPHPのコードでショートコードを作成して対応しました。
mktimeで日を0にすると前月の月末を得られることを利用します。
月は、翌々月を指定して、翌月の月末を取得しています。
add_shortcode( 'gentei_limit', function () {
$next_last_day = mktime(0, 0, 0, date('m') + 2, 0, date('Y'));
$next_y = date('Y', $next_last_day).'年';
$next_m = date('m', $next_last_day).'月';
$next_d = date('d', $next_last_day).'日';
$timestamp = date('Y-m-d', $next_last_day);
$date = date('w', $timestamp);
//配列を使用し、要素順に(日:0〜土:6)を設定する
$week = [
'日', //0
'月', //1
'火', //2
'水', //3
'木', //4
'金', //5
'土', //6
];
//日本語で曜日を出力
$next_w = '(' . $week[$date] . ')';
$out = $next_y . $next_m . $next_d. $next_w;
return $out;
} );