试试这个:
<?php
global $post;
$offerings = get_post_meta($post->ID, "evol_offerings_select", false);
$offeringDefinitions = array(
\'hot\' =>(object)array(\'name\'=>\'Hot 90\', \'temp\'=>\'105\', \'time\'=>\'90\'),
\'flow\' =>(object)array(\'name\'=>\'Flow 75\', \'temp\'=>\'80\', \'time\'=>\'75\'),
\'warm\' =>(object)array(\'name\'=>\'Warm 60\', \'temp\'=>\'90\', \'time\'=>\'60\'),
\'chill\' =>(object)array(\'name\'=>\'Chill 30\', \'temp\'=>\'75-80\', \'time\'=>\'30\'),
\'kids\' =>(object)array(\'name\'=>\'Kids Class\', \'temp\'=>\'comfy\', \'time\'=>\'60\')
);
$offeringsInUse = array();
forEach($offerings as $offering) {
forEach($offeringDefinitions as $offeringName=>$offeringDefinition) {
if ($offering[$offeringName]) $offeringsInUse[$offeringName]=$offeringDefinition;
}
}
?>
<?php if (count($offeringsInUse)>0): ?>
<div class="offerings">
<h3>offerings:</h3>
<?php forEach ($offeringsInUse as $offering): ?>
<div class="single_offering">
<h3><?php echo $offering->name ?></h3>
<p class="class_info">temp: <?php echo $offering->temp ?>° time: <?php echo $offering->time ?>min</p>
</div>
<?php endForEach ?>
</div>
<?php endIf ?>
我在这里所做的是:
预设产品类型的定义。理想情况下,这将是数据驱动的,但显然不是,这是最好的选择请对照以下提供的各种产品检查定义。。。提供*,并将其堆叠到一个数组中如果该数组不是空的,则显示相应的HTML块,并在迭代该数组时填充产品属性实际上,这就是我从您的建议需求中收集到的信息——给定的程序有一组提供的活动,这些活动需要列举出来。。。或者别的什么。也许你可以说得更清楚些。