<?php
$count = count(get_field(‘fieldname’));
?>
<?php
$count = count(get_field(‘fieldname’));
?>
<?php
$acfgroup = get_field('group');
$judge = array_filter($acfgroup);
if(!empty($judge)):
endif;
?>
PHP 2022.8.31
<?php
date_default_timezone_set('Asia/Tokyo');
echo date('Y/m/d H:i:s');
?>
Advanced custom fieldsのチェックボックスで、
チェックの有無による振り分け
$colors = get_field('colors');
if( $colors && in_array('red', $colors) ) {
// Do something.
}
PHP 2017.1.2
キャンペーンなど指定した期間だけバナーを表示したいときなどに簡単に使えるコード
<?php
// キャンペーン期間を指定
if (time() >= strtotime("2017-01-01 00:00:00") && time() < strtotime("2017-03-01 00:00:00")) {
echo "<p>キャンペーンが開始しました</p>";
} else {
echo "<p>キャンペーンは終了しました</p>";
}
?>
<?php
$current_time = strtotime('now');
$target_time = strtotime('2024-12-25 00:00');
if ($current_time < $target_time) {
//期間内
} else {
//期間外
}
?>