Hi,
How is the automatic subnavigation in the sidebar sorted? I would like to be able to sort it either by page id or in the same order as in my main menu. Do I need to edit sidebar.php? If so, please help with some instructions/code mods.
Thanks
Hi akmhou!
Please use this on functions.php:
add_filter('avia_sidebar_menu_args', 'avia_sort_sidebar_pages',10, 2);
function avia_sort_sidebar_pages($args, $post)
{
$args['sort_column'] = 'ID, post_title';
return $args;
}
Best regards,
Ismael
Hi Ismael,
Thanks a lot for the code mod to my child theme functions.php. It worked perfectly!
However, I see a problem with pages already published. Unlike the main menu where I can rearrange the order, the sub navigation doesn’t allow me to make any changes to the order of published pages. I really didn’t want to go into my MySQL db and make those edits there since it can get messy when you change page IDs.
I changed your code from $args[‘sort_column’] = ‘ID, post_title’; to $args[‘sort_column’] = ‘menu_order, post_title’; to make it sort by menu_order instead. This allows me the flexibility to change Page Order # in edit mode quickly and easily.
Thanks for your help.