我正在寻找返回多个get\\u post\\u元数据的解决方案。。。
当前我使用的meta box数组如下所示:
$meta_boxes[] = array(
\'id\' => \'setlist\',
\'title\' => \'Setlist Information\',
\'pages\' => array(\'post\'),
\'fields\' => array(
array(
\'name\' => \'Setlist 1\', // field name
\'desc\' => \'Entry 1\', // field description, optional
\'id\' => $prefix . \'setlist_1\', // field id, i.e. the meta key
\'type\' => \'text\', // text box
\'std\' => \'\', // default value, optional
\'style\' => \'width: 100px\', // custom style for field, added in v3.1
),
array(
\'name\' => \'Setlist 2\',
\'desc\' => \'Entry 2\',
\'id\' => $prefix . \'setlist_2\',
\'type\' => \'text\',
\'std\' => \'\',
\'style\' => \'width: 100px\',
),
依此类推(即setlist\\u 3,4,5,6,7,8….)
在我的单曲里。php我有:
<?php if ( get_post_meta( $post->ID, \'rw_setlist_1\', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, \'rw_setlist_1\', true ); echo "</li>"; ?>
<?php endif; ?>
<?php if ( get_post_meta( $post->ID, \'rw_setlist_2\', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, \'rw_setlist_2\', true ); echo "</li>"; ?>
<?php endif; ?>
<?php if ( get_post_meta( $post->ID, \'rw_setlist_3\', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, \'rw_setlist_3\', true ); echo "</li>"; ?>
<?php endif; ?>
<?php if ( get_post_meta( $post->ID, \'rw_setlist_4\', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, \'rw_setlist_4\', true ); echo "</li>"; ?>
<?php endif; ?>
<?php if ( get_post_meta( $post->ID, \'rw_setlist_5\', true ) ) : echo "<li>"; echo get_post_meta( $post->ID, \'rw_setlist_5\', true ); echo "</li>"; ?>
设置列表值的范围从2到30。。。
说我疯了,但我觉得这种方法会导致不必要的长时间加载,对吗?那么,我该如何为此创建一个更高效的脚本,以“更简单的方式”检查数组中的所有值呢。