Skip to content

Commit

Permalink
added secondary sort for multi-page side navigation to 'page_title' s…
Browse files Browse the repository at this point in the history
…o if orders are not specified it will sort by title alphabetically.
  • Loading branch information
bruffridge committed Nov 16, 2018
1 parent 97772ae commit 5f88839
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"sourceType": "module"
},
"plugins": [
"import",
"import"
],
"settings": {
"import/core-modules": [],
Expand Down
21 changes: 16 additions & 5 deletions app/lib/App/child-navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,29 @@
function wpb_list_child_pages() {
global $post;

$childpages = wp_list_pages( 'sort_column=menu_order&depth=1&title_li=&child_of=' . $post->ID . '&echo=0' );
$args = array(
'title_li' => '',
'child_of' => $post->ID,
'sort_column' => 'menu_order, post_title',
'depth' => 1,
'echo' => false
);

$childpages = wp_list_pages($args);

if (!$childpages && is_page() && $post->post_parent ) {
$childpages = wp_list_pages( 'sort_column=menu_order&depth=1&title_li=&child_of=' . $post->post_parent . '&echo=0' );
$args['child_of'] = $post->post_parent;
$childpages = wp_list_pages($args);
}

$string = '';

if ( $childpages ) {
$string = '<ul class="usa-sidenav-list">' . $childpages . '</ul>';
}

if(function_exists('bwp_external_links')) {
$string = bwp_external_links($string);
if(function_exists('bwp_external_links')) {
$string = bwp_external_links($string);
}
}

return $string;
Expand Down

0 comments on commit 5f88839

Please sign in to comment.