以下腳本向我顯示了我所有商店的清單,並按字母順序排列。現在我想說,例如$ _GET ['letter'] ==「A」;它會告訴我只有以字母A開頭的商店。只選擇一個字母
我該怎麼做?
$stores = get_terms(APP_TAX_STORE, array('hide_empty' => 0, 'parent' => 0));
$list = '';
$groups = array();
// get ids of all hidden stores
$hidden_stores_query = "SELECT ". $wpdb->prefix ."clpr_storesmeta.stores_id FROM ". $wpdb->prefix ."clpr_storesmeta WHERE ". $wpdb->prefix ."clpr_storesmeta.meta_key = 'clpr_store_active' AND ". $wpdb->prefix ."clpr_storesmeta.meta_value = 'no'";
$hidden_stores = $wpdb->get_col($hidden_stores_query);
if ($stores && is_array($stores)) {
foreach($stores as $store)
$groups[strtoupper($store->name[0])][] = $store;
if (!empty($groups)) :
foreach($groups as $letter => $stores) {
$old_list = $list;
$letter_items = false;
$list .= "\n\t" . '<h2 class="stores" id="' . apply_filters('the_title', $letter) . '">' . apply_filters('the_title', $letter) . '</h2>';
$list .= "\n\t" . '<ul class="stores">';
foreach($stores as $store) {
if (!in_array($store->term_id, $hidden_stores)) {
$list .= "\n\t\t" . '<li><a href="' . get_term_link($store, APP_TAX_STORE) . '"><img src="/images/korting-winkels/'. ereg_replace("[^A-Za-z0-9]", "", strtolower(apply_filters('the_title', $store->name))).'.png" width="133" class="afbeelding" height="68" alt="' . apply_filters('the_title', $store->name). '" title="' . apply_filters('the_title', $store->name). '" /></a><br /></li>';
$letter_items = true;
}
}
$list .= "\n\t" . '</ul>';
if(!$letter_items)
$list = $old_list;
}
endif;
} else {
$list .= "\n\t" . '<p>' . __('Sorry, but no stores were found.', 'appthemes') .'</p>';
}