現在「完了」、進捗 0%。工程は全4件中 3件完了。
残りの工程: ご確認・修正
exciteエピで作成していただきたいショートコードがあります。
記事タイトルに「21年7月」などの情報を入れたいと思っておりまして、
毎月変更せずに、現在の日付から自動で変化するようにできればと思っています。
・2021
・21
・7
この3パターンで記事タイトルに使用できて、投稿記事、カテトップとも使用が可能なものが希望
年(4桁)/type=Y :[date_get type=Y]
年(2桁)/type=y :[date_get type=y]
月(先頭の0あり)/type=M :[date_get type=M]
月(先頭の0なし)/type=m :[date_get type=m]
日(先頭の0あり)/type=D :[date_get type=D]
日(先頭の0なし)/type=d :[date_get type=d]
/---------------------------------------------------------------------------------/
// 日付取得ショートコード 2021/08/02追加
/---------------------------------------------------------------------------------/
date_default_timezone_set('Asia/Tokyo');
$DATE_Y = date("Y");
$DATE_y = date("y");
$DATE_M = date("m");
$DATE_m = date("n");
$DATE_D = date("d");
$DATE_d = date("j");
// 日付取得ショートコード [ date_gete type="Y"]
function shortcode_date_get($atts) {
global $DATE_Y,$DATE_y,$DATE_M,$DATE_m,$DATE_D,$DATE_d;
extract(shortcode_atts(array(
'type' => "Y",
), $atts));
if($type=="Y"){
$res = $DATE_Y;
}else if($type=="y"){
$res = $DATE_y;
}else if($type=="M"){
$res = $DATE_M;
}else if($type=="m"){
$res = $DATE_m;
}else if($type=="D"){
$res = $DATE_D;
}else if($type=="d"){
$res = $DATE_d;
}else {
$res = $type;
}
return $res;
}
add_shortcode('date_get', 'shortcode_date_get');
コメントはありません。