0
我想用木材(树枝)和Wordpress创建一本字典。获取与木材(树枝)和Wordpress的信件
我得到我的信,但数组我需要生成的字母列表:一个 - B - C - d ...
$query = new WP_Query(array('post_type' => 'lexique', 'posts_per_page' => -1));
$by_letter = array();
while($query->have_posts()) { $query->the_post();
$letter = substr($post->post_name, 0, 1);
if (! isset($by_letter[$letter])) $by_letter[$letter] = array();
$by_letter[$letter][] = $post;
}
if (!empty($by_letter)) {
ksort($by_letter);
}
$context['query_lexique'] = $by_letter;
所以我需要采取的第一个字母[A] [B ]在此:
Array
(
[a] => Array
(
[0] => WP_Post Object
(
[ID] => 239
[post_author] => 1
[post_date] => 2016-12-29 14:22:03
[post_date_gmt] => 2016-12-29 13:22:03
)
[1] => WP_Post Object
(
[ID] => 238
[post_author] => 1
[post_date] => 2016-12-29 14:21:34
[post_date_gmt] => 2016-12-29 13:21:34
)
)
[b] => Array
(
[0] => WP_Post Object
(
[ID] => 241
[post_author] => 1
[post_date] => 2016-12-29 16:34:28
[post_date_gmt] => 2016-12-29 15:34:28
)
[1] => WP_Post Object
(
[ID] => 240
[post_author] => 1
[post_date] => 2016-12-29 16:34:07
[post_date_gmt] => 2016-12-29 15:34:07
)
)
)
如何让每个字母生成我的列表?
可能的重复[显示Wordpress自定义帖子类型的第一个字母与木材(树枝)](http://stackoverflow.com/questions/41384337/displaying-wordpress-custom-post-type-by-first -letter与 - 木树枝) – Gchtr