I'm working on a website bilt with wordpress. I've included a select type menu with the name and links of my children pages of one parent page. everything works fine, my pages are sorted alphabetically ASC :
Bali
Bruxelles
Chicago
Edinburgh
Geneve
Los Angeles
Lyon
Miami
Paris
San Diego
San Francisco
Vancouver
Washington
Zurich
here is my code :
<div class="styled-select">
<?php
if(!$post->post_parent){
$children = get_pages(array(
'child_of' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish',
'sort_order' => 'ASC',
'sort_column' => 'post_title',
));
}else{
$children = get_pages(array(
'child_of' => $post->post_parent,
'post_type' => 'page',
'post_status' => 'publish',
'sort_order' => 'ASC',
'sort_column' => 'post_title',
));
}
if ($children) {
echo '<select name="" onchange="location = this.options[this.selectedIndex].value;">';
echo '<option>'. 'A - Z' .'</option>';
foreach($children as $child){
//print_r($child);
$permalink = get_permalink($child->ID);
echo '<option value="'.$permalink.'">'.$child->post_title.'</option>';
}
echo '</select>';
} ?>
</div>
I wanted to know if its possible to add automatically an alphabet index (width in guess) inside my menu, like this. add "A" in before all pages beginning with A (when there are pages beginning with A...), add "B" in before all pages beginning with B, and so on... Something who must look like this :
A
B
Bali
Bruxelles
C
Chicago
D
E
F
Edinburgh
G
Geneve
H
I
J
K
L
Los Angeles
Lyon
M
Miami
N
O
P
Paris
Q
R
S
San Diego
San Francisco
T
U
V
Vancouver
W
Washington
X
Y
Z
Zurich
If anybody know who I can do it it would be much appreciate ! thanks a lot
Mattieu