I am trying to set a default post order for viewing my pages/posts in the WP backend. The function itself is working fine (tested with another theme) but with Sage 8.x it just won’t work…
I read up upon https://roots.io/upping-php-requirements-in-your-wordpress-themes-and-plugins and put the function into extras.php with the Namespacing added accordingly (tried functions.php first) but also there no changes.
This is my function now and I think I used the right formatting, right?
/**
* Change default Admin Page Ordering
*/
function set_post_order_in_admin( $wp_query ) {
global $pagenow;
if ( is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) {
$wp_query->set( 'orderby', 'title' );
$wp_query->set( 'order', 'DESC' );
}
}
add_filter('pre_get_posts', __NAMESPACE__ . '\\set_post_order_in_admin', 5 );
What can possibly be the issue here? WP_DEBUG doesn’t show any info…
Thanks in advance & regards,
Henning