Vous souhaitez déplacer votre métabox auteur du bas de la page vers la métabox publier l’article ? Cela s’avère utile si vous gérez un blog à plusieurs auteurs et que vous publiez la plupart de vos articles en tant qu’équipe éditoriale. De cette façon, vous pouvez facilement changer l’auteur sans avoir à faire défiler la métabox de l’auteur. Cet extrait vous rappelle également de modifier l’auteur avant de publier l’article.
Instructions:
Tout ce que vous avez à faire est d’ajouter ce code dans le fichier functions.php de votre thème ou dans un plugin spécifique à votre site:
add_action( 'admin_menu', 'remove_author_metabox' ); add_action( 'post_submitbox_misc_actions', 'move_author_to_publish_metabox' ); function remove_author_metabox() { remove_meta_box( 'authordiv', 'post', 'normal' ); } function move_author_to_publish_metabox() { global $post_ID; $post = get_post( $post_ID ); echo '<div id="author" class="misc-pub-section" style="border-top-style:solid; border-top-width:1px; border-top-color:#EEEEEE; border-bottom-width:0px;">Author: '; post_author_meta_box( $post ); echo '</div>'; }
Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez vous référer à notre guide sur comment copier/coller correctement des extraits de code dans WordPress, afin de ne pas casser accidentellement votre site.
Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : Les meilleurs constructeurs de pages WordPress (comparés).
Got a way to open all publish metabos options by default so status, visibility and publish date are completely viewable by default?
Got a way to open all publish metabos options by default so status, visibility and publish date are completely viewable by default?
Got a way to open all publish metabos options by default so status, visibility and publish date are completely viewable by default?
Got a way to open all publish metabos options by default so status, visibility and publish date are completely viewable by default?
Got a way to open all publish metabos options by default so status, visibility and publish date are completely viewable by default?
Got a way to open all publish metabos options by default so status, visibility and publish date are completely viewable by default?
Hi Kevin. I tried this snippet and the author box displays in the metabox as intended, but when I save, it doesn’t ‘stick’. Maybe it’s conflicting with another plugin or function, maybe not. Just wanted to report that.
thanks for the snippet. However, I tried this snippet on a multisite test site and discovered that all authors in the WP site are also included in the drop downmenu, when moved to the publish post metabox. However, I may select any author name I like but do not have permission to publish anything. Just can save a post.
Hi Zeb,
I never tested this out on wpmu but it works great within single user wordpress version. Saves time rather then scrolling to the bottom of the page. However that it good to know that it will not work properly on MU.
Yes, Kevin thats why I liked it and tried to implement it to save time. It’s great and I’ll definitly use it in my single installation (thanks to you) 🙂 , but in MU, I have to wait for an improved version.
Hi Zeb agreed, I’m sure ill post an update in the near future.