function save_event($params) { if (get_post_type($params['post_data']['ID']) == CFS_LFQ_POST_TYPE && CFS()->get(CFS_LFQ_CFS_LOOP, $params['post_data']['ID'])) { global $wpdb; $postID = $params['post_data']['ID']; $fields = CFS()->get(CFS_LFQ_CFS_LOOP, $postID); sortArrayByKey($fields, CFS_LFQ_CFS_LOOP_DATE); // sorting by "date" $sql = 'DELETE FROM ' . TABLE_NAME . " WHERE post_id = {$postID};"; $sql = $wpdb->prepare($sql); $result = $wpdb->query($sql); foreach ($fields as $field) { $date = str_replace('-', '', $field[CFS_LFQ_CFS_LOOP_DATE]); if ($field[CFS_LFQ_CFS_LOOP_STARTTIME]) { $stime = str_replace(':', '', $field[CFS_LFQ_CFS_LOOP_STARTTIME] . ':00'); } else { $stime = 'null'; } if ($field[CFS_LFQ_CFS_LOOP_FINISHTIME]) { $ftime = str_replace(':', '', $field[CFS_LFQ_CFS_LOOP_FINISHTIME] . ':00'); } else { $ftime = 'null'; } $sql = 'INSERT INTO ' . TABLE_NAME . " (post_id, date, starttime, finishtime) VALUES ({$postID}, {$date}, {$stime}, {$ftime});"; $sql = $wpdb->prepare($sql); $result = $wpdb->query($sql); } } }
<?php $tmpData[$j]["title"] = get_the_title(); $tmpData[$j]["price"] = $product->get_price_html(); $tmpData[$j]["content"] = get_the_content(); $tmpData[$j]["product_id"] = $loop->post->ID; $tmpData[$j]["sku"] = $product->get_sku(); $j++; ?> <?php } ?> <?php wp_reset_query(); ?> <?php sortArrayByKey($tmpData, 'sku'); $h = 0; foreach ($tmpData as $key => $value) { ?> <li class="product"> <div class="item-detail"> <h3><?php echo $value["title"]; ?> - <span class="price"><?php echo $value["price"]; ?> </span></h3> <p><?php echo $value["content"]; ?>