Ordinamento custom dei posts in Wordpress admin
I posts nella sezione admin di Wordpress sono ordinati di default per data.
Cosa che non mi piace, in quanto trovo più comodo l'ordinamento per nome.
Possiamo facilmente customizzare l'ordine aggiungendo questo codice al functions.php:
function ordinamento_posts_custom($query): void {
$post_types = get_post_types(array('_builtin' => true), 'names');
$post_type = $query->get('post_type');
if (in_array($post_type, $post_types)) {
if ($query->get('orderby') == '') {
$query->set('orderby', 'title');
}
if ($query->get('order') == '') {
$query->set('order', 'ASC');
}
}
}
if (is_admin()) {
add_action('pre_get_posts', 'ordinamento_posts_custom');
}
Enjoy!
php wordpress pre_get_posts
1 Commenti
Chekhoslovakia for us were shaken by the almost all mentioned so that somebody
05/12/2024