Comment modifier l'ordre des catégories dans le tableau de bord d'administration?
3 réponses
- votes
-
- 2012-05-24
J'aitrouvé une réponse dans cette réponse .
add_filter( 'get_terms_args', 'wpse_53094_sort_get_terms_args', 10, 2 ); function wpse_53094_sort_get_terms_args( $args, $taxonomies ) { global $pagenow; if( !is_admin() || ('post.php' != $pagenow && 'post-new.php' != $pagenow) ) return $args; $args['orderby'] = 'slug'; $args['order'] = 'DESC'; return $args; }
La commande peut être
ASC
ouDESC
,et la commandepar peut être:count
-
description
(cela devrait,maisn'apastrèsbien fonctionnépourmoi,destests supplémentaires sontnécessaires) name
slug
Plugins d'intérêt
(pouvons-nous appeler ces Plinterests
Les deuxpremiers sonttrès courtset peuvent êtrefacilementincorporés dans votre code.
-
Expanseur de la liste de contrôle des catégories : augmente la hauteur du liste de catégories,donc aucun défilementn'estnécessaire
-
Arbre de la liste de contrôle des catégories : celui-ci reconstruit la catégorie Meta Box,afin que vouspuissiezmodifier son codepourplus de style/adapter laboîte -et voici une capture d'écran de ce qu'ellefait
-
Commande destermes Gecka : crée unetable auxiliaire dans labase de données (
wp_termmeta
)pourgérer la commande. Possède des capacités deglisser-déposer.
Found an answer in this answer.
add_filter( 'get_terms_args', 'wpse_53094_sort_get_terms_args', 10, 2 ); function wpse_53094_sort_get_terms_args( $args, $taxonomies ) { global $pagenow; if( !is_admin() || ('post.php' != $pagenow && 'post-new.php' != $pagenow) ) return $args; $args['orderby'] = 'slug'; $args['order'] = 'DESC'; return $args; }
The order may be
ASC
orDESC
, and the orderby can be:count
description
(it should, but didn't work so well for me, futher tests necessary)name
slug
Plugins of interest
(may we call those Plinterests?)
The first two are very short and and can be easily incorporated into your code.
Category Checklist Expander : expands the height of the category list, so no scrolling is needed
Category Checklist Tree : this one rebuilds the Category Meta Box, so you can modify its code for further styling/adapting the box - and here's a screenshot of what it does
Gecka Terms Ordering : creates an auxiliary table in the database (
wp_termmeta
) to deal with the ordering. Has drag and drop capabilities.
-
Mercibeaucoup![enplus de cesplugins,j'ai également écrit un code court quiexécute des catégories dans l'arborescence]Thank you very much! [in addition to those plugins, I also wrote a short code that performs categories in tree veiw]
- 0
- 2012-05-25
- Shimon S
-
Jeme demande,commentpuis-je afficher untermeparticulieren haut?I wonder, how can I show a particular term on the top?
- 0
- 2012-05-25
- Shimon S
-
Peut-être que lemoyen leplus simple serait demanipuler le DOMjQuery,vérifiez [cette réponse] (http://wordpress.stackexchange.com/a/53143/12615)pourtrouver l'inspiration :)Maybe, the easiest way would be jQuery DOM manipulation, check [this answer](http://wordpress.stackexchange.com/a/53143/12615) for inspiration :)
- 0
- 2012-05-25
- brasofilo
-
@ s976 -j'ai oublié de voustaguer dansmon commentaireprécédent ... Leplugin de scribu,CCT,a quelquesjQuerypourfaire défiler automatiquement la liste,vouspouvez également obtenir desidées àpartir de là.@s976 - forgot to tag you in my previous comment... scribu's plugin, CCT, has some jQuery to auto-scroll the list, you can get some ideas from there too.
- 0
- 2012-05-25
- brasofilo
-
- 2016-09-28
Utilisez leplugin Advanced Custom Fields (cepluginestpratique de différentesmanières).Ensuite,créez un champ de commandepersonnalisé (category_order) avec la règle «Taxanomy_Term»est égal à «Catégories».
Ensuite,dans votrethèmefunctions.php (ou quelquepartpertinent),utilisez:
$categories = get_categories( $args ); usort($categories, function($a, $b) { return get_field("category_order", "category_".$a->term_id) - get_field("category_order", "category_".$b->term_id); }); foreach ($categories as $category){ ...
Où category_orderest lenom du champ que vous avez créé avec ACF.
Cemessageinspiré de celui-ci ici .
Use the plugin Advanced Custom Fields (This plugin is handy in many different ways). Then create an custom order field (category_order) with the rule 'Taxanomy_Term' is equal to 'Categories'.
Then in your theme functions.php (or somewhere relevant) use:
$categories = get_categories( $args ); usort($categories, function($a, $b) { return get_field("category_order", "category_".$a->term_id) - get_field("category_order", "category_".$b->term_id); }); foreach ($categories as $category){ ...
Where category_order is the field name you created with ACF.
This post inspired by this one here.
-
C'étaitexactement ce queje cherchaiset celafonctionnebien pour lestaxonomiespersonnalisées aussi,changez simplement 'category_'par lenom de votretaxonomie.This was a exactly what I was looking for and it works fine for custom taxonomies too, just change 'category_' to the name of your taxonomy.
- 0
- 2017-07-01
- Thomas Bindzus
-
- 2012-05-23
Iln'y apas d'optionpar défautpour cela,maisil y a deux autresfaçons.
- Modifiez-le dans lesfichiers dethème http://codex.wordpress.org/Template_Tags/wp_list_categories
- Utilisez unplugin.Parexemple, http://wordpress.org/extend/plugins/my-category-order/
There's no default option for it, but there's two other ways.
- Change it in the theme files http://codex.wordpress.org/Template_Tags/wp_list_categories
- Use a plugin. Eg http://wordpress.org/extend/plugins/my-category-order/
-
Jepense que votre suggestionestpour les utilisateurs.Etje cherche commentmodifier la commande côté administrateur.I think that you sugestion is for users side. And I am looking for how to change the order on a admin side.
- 0
- 2012-05-24
- Shimon S
-
Ces deux suggestions sont destinées aux administrateurs.Les utilisateursne devraient vraimentpas avoir accès auxfichiers dethème,et si vous regardez lesinstructions duplugin,celaparle clairement de l'utilisation de l'administrateur.Both of those suggestions are for admins. Users really shouldn't have any access to the theme files, and if you look at the instructions for the plugin, it's clearly talking about admin use.
- 0
- 2012-05-24
- user1337
-
@ user1337 - vous confondez l'utilisateur "admin" (ou ayant despouvoirs administratifs sur un site) avec lebackend WordPress,également appelé Admin ou Dashboard.@user1337 - you are confusing the user "admin" (or having administrative powers over a site) with WordPress backend, also referred as Admin or Dashboard.
- 0
- 2012-05-24
- brasofilo
-
@brasofilo - Pas dutout.Soit l'utilisateur «admin» ou quelqu'un qui a accès auplugin à l'admin ou autableau debordpeutinstaller cepluginet changer l'ordre dans lequel les catégories sont répertoriées. Onpeut également utiliser unplugin de rôlespour déléguer cette capacité à d'autres rôles à côté de l'administrateur.@brasofilo - Not at all. Either the user "admin" or someone who has plugin access to the admin or dashboard can install that plugin and change the order that categories are listed in. One can also use a roles plugin to delegate that ability to other roles beside the administrator.
- 0
- 2012-05-24
- user1337
-
Lepluginfonctionnera-t-il dans [cetteméta-boîte] (http://cl.ly/1O3v332G0W0n3w1F1J3F)?Will the plugin work in [this meta box](http://cl.ly/1O3v332G0W0n3w1F1J3F)?
- 0
- 2012-05-24
- brasofilo
L'ordre des catégories sur letableau debordest alphabétique.Puis-je le changeren commandepersonnalisée?