CMB2 metabox conditional logic
The best way to do this is by using JavaScript and there is a couple of CMB2 plugins let you do that easily: CMB2 Conditional CMB2 Conditional Logic
The best way to do this is by using JavaScript and there is a couple of CMB2 plugins let you do that easily: CMB2 Conditional CMB2 Conditional Logic
For the part of opening a lightbox, browse for something and then performing something on an action within: WordPress has this already build in. For what you ask is basically the thickbox that opens up like in the post editor when you browse for an image in the gallery. You find all the code you … Read more
I couldn’t find a hook so I went with the JS option. add_action( “admin_head-post-new.php”, ‘meta_box_instruction’ ); //new post add_action( “admin_head-post.php”, ‘meta_box_instruction’ ); //edit post function meta_box_instruction($d) { global $post; if($post->post_type == ‘{YOUR POST TYPE}’ || $_GET[‘post_type’] == ‘{YOUR POST TYPE}’): ?> <script type=”text/javascript”> jQuery(document).ready(function(){ jQuery(‘<p>Some instruction</p>’).insertBefore(‘#taxonomy-{YOUR TAXONOMY NAME}’).parent(); }); </script> <?php endif; }
Those are 2 different things: Hide only in one Page Hide only when Page uses a specific template Case 1 – in this example the Page ID is 3, but note that the removals are for page and post alike: add_action( ‘admin_menu’, ‘remove_post_meta_boxes’ ); function remove_post_meta_boxes() { if( isset( $_GET[‘post’] ) && $_GET[‘post’] == ‘3’ … Read more
I’ve dabbled in this as well. For a meta box I recommend the Meta Box plugin (which I regularly contribute code to). A good tutorial on how to use it is here. For custom columns, do a search in WPSE but this should get you started. Saving the post title involves using the save_post filter. … Read more
You just need to override the function display_tablenav() with a blank function in you parent class. It is explained here.
If you want to hide all the metaboxes for all users, you can do that through the get_user_option_metaboxhidden_{cpt}, default_hidden_meta_boxes or the hidden_meta_boxes filter, according to the /wp-admin/includes/screen.php file. Here’s an example for the post post type: /** * Hide all metaboxes in the global $wp_meta_boxes */ add_filter( ‘hidden_meta_boxes’, function( $hidden, $screen, $use_defaults ) { global … Read more
Wrong Assumptions @Rarst or @Dan-Cameron answers may work, but assume that when you are viewing a post type editing page, the metaboxes for the other post type are all registered. There are different case in which that won’t happen: If metaboxes are registered using “add_meta_boxes_{$post_type}” hook, instead of the more common, generic “add_meta_boxes” they won’t … Read more
As is often the case in WP, there are a number of ways to attack this problem. Here’s one possible way: function my_meta_box_order() { global $wp_meta_boxes; $genre = $wp_meta_boxes[‘post’][‘side’][‘core’][‘genrediv’]; unset($wp_meta_boxes[‘post’][‘side’][‘core’][‘genrediv’]); $wp_meta_boxes[‘post’][‘side’][‘core’] = array(‘genrediv’ => $genre) + $wp_meta_boxes[‘post’][‘side’][‘core’]; } add_action(‘add_meta_boxes_post’, ‘my_meta_box_order’); # We’re hooking into: do_action(‘add_meta_boxes_’ . $post_type, $post); $wp_meta_boxes holds all the meta box information. … Read more
You are using checkfield_<?php echo $page->ID; ?> as name for your input fields, then trying to save $_POST[‘checkfield’] which is not set. You can do the same $pages loop on the myplugin_meta_save() function and then save the data for each page as separate meta_key input (checkfield_1, checkfield_5, etc), OR you can save all that data … Read more