我想这样试试。使用元查询获取事件列表并将所有内容加载到datatable. 这似乎是让来访者进行筛选和分类的最佳时机。
下面是一个简单的实现(可能需要调整)。只需从函数调用或模板中打印或返回“$disp\\U data”变量。如果您没有设置datatable,我可以帮助您。否则,只需更新下面的html并使用查询
$disp_data = \'<div class="data-display"><script>
jQuery(document).ready(function() {
jQuery("#my-events-table").dataTable( {
columnDefs: [ {
targets: [ 0 ],
orderData: [ 0, 1 ]
}, {
targets: [ 1 ],
orderData: [ 1, 0 ]
}, {
targets: [ 3 ],
orderData: [ 3, 0 ]
} ]
} );
} );
</SCRIPT>
<TABLE id="my-events-table" class="display" cellspacing="0" ><thead>
<tr>
<th>Date</th>
<th>Venue</th>
<th>Venue</th>
<th>Venue</th>
</tr>
</thead>
<TBODY>\';
$args = array(
\'post_type\' => \'my-event-type\',
\'posts_per_page\' => -1,
\'orderby\' => \'meta_value\',
\'order\' => \'ASC\',
\'meta_key\' => \'acf-field\',//custom field name holding event date
\'meta_query\' => array(
array(
\'key\' => \'_my-datetime-from\',
\'value\' => array($start, $end),
\'compare\' => \'BETWEEN\',
\'type\' => \'DATE\'
)
)
);
$posts = new WP_Query( $args );
foreach ( $posts as $post ) {
/*get you acf values here and load in to a table row*/
$disp_data .= \'<tr>
<td>\' . $cur_property . \'</td>
<td>\' . $venue . \'</td>
<td>\' . $venue . \'</td>
<td>\' . $venue . \'</td>
</tr>\';
}
wp_reset_postdata();
$disp_data .= \'</tbody></table></div>\';