[ad_1]
Thread Starter
gm1980
(@gaurav1980)
Hi @gaurav1980,
I am not sure how this function is called (which hook and priority), but it appears to be executed before the $permalink_manager_uris global is populated with data. Because the variable’s value is null, ksort() returns an error.
You should keep two things in mind:
- Make sure the variable is indeed an array before trying to sort it
- Make sure that your code is called after the $permalink_manager_uris variable is filled with data
The “plugins_loaded” hook with priority 10 is the first time you can run the sorting function.
//* Permalink Manager Required
function pm_custom_uris_order() {
global $permalink_manager_uris;
if(is_array($permalink_manager_uris)) {
krsort($permalink_manager_uris);
}
}
add_action('plugins_loaded', 'pm_custom_uris_order', 10);Best regards,
Maciej
