How to HIDE everything in PUBLISH metabox except Move to Trash & PUBLISH button

You can simply hide the options using CSS. This will add a display:none style to the misc and minor publishing actions on the post.php and post-new.php pages. It checks for a specific post type as well since all post types use these two files. function hide_publishing_actions(){ $my_post_type=”POST_TYPE”; global $post; if($post->post_type == $my_post_type){ echo ‘ <style … Read more

Custom field/meta populated by dropdown of existing posts?

As the author of WPAlchemy, I’m a bit bias, but you essentially have a good working model outlined to follow depending on what ever route you choose. However, if using WPAlchemy, you would basically do something like the following (step #2): // functions.php include_once ‘WPAlchemy/MetaBox.php’; if (is_admin()) { // a custom style sheet if you … Read more

Metabox with checkbox is not updating

Here is code I have used before – the main difference looks to me that you are checking if the meta exists rather than what it’s value is to determine if it should be checked. // Checkbox Meta add_action(“admin_init”, “checkbox_init”); function checkbox_init(){ add_meta_box(“checkbox”, “Checkbox”, “checkbox”, “post”, “normal”, “high”); } function checkbox(){ global $post; $custom = … Read more

Does WordPress have a “Form API”?

No, but it should 😉 There are several custom field class’s (backend). wpAlchemy : https://github.com/farinspace/wpalchemy Meta Box Script: https://github.com/rilwis/meta-box My-Meta-Box: https://github.com/bainternet/My-Meta-Box meta-box-class: https://github.com/corycrowley/meta-box-class Meta Boxes Class: https://github.com/Bakke/Wordpress-Custom-Meta-Boxes-Class For front-end forms, you probably best off with a plugin in Eugene Manuilov’s link.

Trigger Javascript on Gutenberg (Block Editor) Save

Not sure if there is a better way, but I am listening to subscribe rather than adding an event listener to the button: wp.data.subscribe(function () { var isSavingPost = wp.data.select(‘core/editor’).isSavingPost(); var isAutosavingPost = wp.data.select(‘core/editor’).isAutosavingPost(); if (isSavingPost && !isAutosavingPost) { // Here goes your AJAX code …… } }) Official docs of the Post Editor data: … Read more

Is there an easy way to make a meta box have the tabs like the Categories meta box has?

Here’s a very basic example.. /* Code assumes it will be in the theme functions.php file Update the enqueue path if using it elsewhere */ add_action( ‘add_meta_boxes_post’, ‘add_post_metabox’ ); function add_post_metabox() { wp_enqueue_script( ‘mytabs’, get_bloginfo( ‘stylesheet_directory’ ). ‘/mytabs.js’, array( ‘jquery-ui-tabs’ ) ); add_meta_box( ‘examplebox’ , __(‘Example box’), ‘my_example_metabox’, ‘post’, ‘side’, ‘core’/*,array()*/); } function my_example_metabox() { … Read more

Help Creating a Slideshow Custom Post Type with Custom Meta Boxes?

From the looks of things, your safest bet and easiest route would be to fork the More Fields plugin specifically for your use. The two biggest features I can see your fork needing are a field “factory” and a drag-and-drop interface. Multiple Fields My suggestion would be to look at the WordPress Widget class and … Read more

How to change default position of WP meta boxes?

You can remove the default meta boxes with remove_meta_box and re-add them in a different position with add_meta_box: add_action(‘do_meta_boxes’, ‘wpse33063_move_meta_box’); function wpse33063_move_meta_box(){ remove_meta_box( ‘postimagediv’, ‘post’, ‘side’ ); add_meta_box(‘postimagediv’, __(‘Featured Image’), ‘post_thumbnail_meta_box’, ‘post’, ‘normal’, ‘high’); } This will remove it from the side column and add it to the main column. change post in this example … Read more