Comment puis-je mettre une méta-boîte personnalisée au-dessus de l'éditeur mais sous la section titre de la page d'édition de l'article?
-
-
Questiontrès similaireici: http://wordpress.stackexchange.com/questions/35416/re-order-editor-to-be-after-meta-boxVery similar question here: http://wordpress.stackexchange.com/questions/35416/re-order-editor-to-be-after-meta-box
- 0
- 2014-08-29
- Simon East
-
4 réponses
- votes
-
- 2013-02-23
- Ajoutez simplement uneméta-boîteen utilisant le contexte avancé et la haute priorité
- Ensuite,accrochez-vous au crochet
edit_form_after_title
-
Imprimez vosméta-boîtes là-bas,puis supprimez-lespour qu'ellesn'apparaissentpas deuxfois.
// Move all "advanced" metaboxes above the default editor add_action('edit_form_after_title', function() { global $post, $wp_meta_boxes; do_meta_boxes(get_current_screen(), 'advanced', $post); unset($wp_meta_boxes[get_post_type($post)]['advanced']); });
- Simply add a meta box using the advanced context, and high priority
- Then, latch on to the
edit_form_after_title
hook Print your meta boxes out there, then remove it so it doesn't appear twice.
// Move all "advanced" metaboxes above the default editor add_action('edit_form_after_title', function() { global $post, $wp_meta_boxes; do_meta_boxes(get_current_screen(), 'advanced', $post); unset($wp_meta_boxes[get_post_type($post)]['advanced']); });
-
Un site sur lequelje travailleenregistre certainesmétaboxesen utilisant leparamètre `register_meta_box_cb` de lafonction` register_post_type`.J'aiessayé votre codemais lesmétaboxesne se déplacentpas au-dessus de l'éditeur.Celapeut-il être utilisé dansmon cas?MerciA site I'm working on registers some metaboxes using the `register_meta_box_cb` parameter of the `register_post_type` function. I've tried your code but the metaboxes don't move above the editor. Can this be used in my case? Thanks
- 0
- 2016-08-28
- leemon
-
Je recommanderais d'utiliser un `$ context`personnalisé,au lieu de` advanced`,utilisez quelque chose comme `my_before_editor`,afin dene pas déplacertoutes lesméta-boîtes dans le contexte` avancé`,vous ciblez spécifiquement vosméta-boîtes spécifiques .. voirhttps://developer.wordpress.org/reference/functions/add_meta_box/I would recommend using a custom `$context`, instead of `advanced`, use something like `my_before_editor`, so that you do not move all meta boxes in the `advanced` context, you specifically target your specific meta boxes .. see https://developer.wordpress.org/reference/functions/add_meta_box/
- 0
- 2017-12-08
- farinspace
-
- 2014-08-20
Voici comment déplacer desméta-boîtes spécifiques au-dessus de l'éditeur,mais avant depublier le code,je voudrais simplement remercier Andrewet mhulse.Vous êtes rock!
function foo_deck( $post_type ) { if ( in_array( $post_type, array( 'post', 'page' ) ) ) { add_meta_box( 'contact_details_meta', 'Contact Details', 'contact_details_meta', $post_type, 'test', // change to something other then normal, advanced or side 'high' ); } } add_action('add_meta_boxes', 'foo_deck'); function foo_move_deck() { # Get the globals: global $post, $wp_meta_boxes; # Output the "advanced" meta boxes: do_meta_boxes( get_current_screen(), 'test', $post ); # Remove the initial "advanced" meta boxes: unset($wp_meta_boxes['post']['test']); } add_action('edit_form_after_title', 'foo_move_deck');
Here is how you can move specific meta boxes above the editor, but before I post the code I just would like to thank Andrew and mhulse. You guys rock!
function foo_deck( $post_type ) { if ( in_array( $post_type, array( 'post', 'page' ) ) ) { add_meta_box( 'contact_details_meta', 'Contact Details', 'contact_details_meta', $post_type, 'test', // change to something other then normal, advanced or side 'high' ); } } add_action('add_meta_boxes', 'foo_deck'); function foo_move_deck() { # Get the globals: global $post, $wp_meta_boxes; # Output the "advanced" meta boxes: do_meta_boxes( get_current_screen(), 'test', $post ); # Remove the initial "advanced" meta boxes: unset($wp_meta_boxes['post']['test']); } add_action('edit_form_after_title', 'foo_move_deck');
-
«changerpour quelque chose d'autre quenormal,avancé ou latéral» - était la clé dansmon cas.Mercipour l'info.`change to something other then normal, advanced or side` -was the key in my case. Thanks for the info.
- 1
- 2014-09-28
- Mayeenul Islam
-
C'était la réponse laplus utilepourmoi.Je vous remercie!This was the most helpful answer to me. Thank you!
- 0
- 2018-12-04
- marvinpoo
-
- 2016-03-19
Au lieu detout déplacer dans la section avancée vers le haut,pourquoine pas créer unenouvelle sectionet la déplacer vers le haut:
// Create 'top' section and move that to the top add_action('edit_form_after_title', function() { global $post, $wp_meta_boxes; do_meta_boxes(get_current_screen(), 'top', $post); unset($wp_meta_boxes[get_post_type($post)]['top']); });
Ilne vous resteplus qu'àenregistrer laméta-boxen utilisant
top
pour la sectionethigh
pour lapriorité.Celafonctionne sur WordPress 4.4.2pourmoi.Jen'aipastesté cela sur d'autres versions de WP.
Instead of moving everything in the advanced section to the top, why not create a new section and move that to the top:
// Create 'top' section and move that to the top add_action('edit_form_after_title', function() { global $post, $wp_meta_boxes; do_meta_boxes(get_current_screen(), 'top', $post); unset($wp_meta_boxes[get_post_type($post)]['top']); });
Now all you need to do is register the meta box using
top
for the section andhigh
for the priority.It's working on WordPress 4.4.2 for me. I haven't tested this on other WP versions.
-
- 2016-05-26
Ilexiste un autremoyen,en passant,nouspouvonsplacer l'éditeur àn'importe quelleposition:
-
Supprimer l'éditeur duparamètre de support lorsque vousenregistrezpost_type
-
ajouter unefaussemetabox
add_meta_box( 'does-not-matter', __( 'Description'), function($post){ wp_editor($post->post_content,'post_content',array('name'=>'post_content')); }, 'post_type_type', 'advanced', 'high' );
There is an other way, by the way we can put the editor to any position:
Remove editor from support param when you register post_type
add a fake metabox
add_meta_box( 'does-not-matter', __( 'Description'), function($post){ wp_editor($post->post_content,'post_content',array('name'=>'post_content')); }, 'post_type_type', 'advanced', 'high' );
-
Pourinfo,celafonctionnetoujours,mais lorsque vous déplacez laboîte,celaprovoque un comportement étrange avec le contenu du champ.Attention aux utilisateurs.FYI, this still works, but when you move the box it causes some weird behavior with the content of the field. Users beware.
- 0
- 2018-02-12
- Eckstein
J'ai uneméta-boîtepersonnaliséepour untype depublicationpersonnalisé quemon client souhaiteplacerentre la sectiontitre/lienpermanentet l'éditeur depublication dans lepanneau d'administration.Est-cepossibleet si oui,y a-t-il un hook/filter/etc quej'auraisbesoin d'utiliser?