Make metabox always be on top (sticky)
Make metabox always be on top (sticky)
Make metabox always be on top (sticky)
Never mind , i was hooking the metaboxes on plugin_run() Moved them to admin_menu() and now it works OK Regards
Ok, I found the answer. It’s a quite stupid copy/paste mistake. The name of my nonce_field was not unique. I had already created another nonce from the same plugin but another file. Therefore the basename(__FILE__) value was different leading to a different nonce. All I had to do was change the the name of the … Read more
Metabox on a custom page – How to include the appropriate default scripts and styles?
So, after an annoyingly long struggle, I discovered that I needed to have the script enqueued/registered with no dependencies. So in the end, to make it work, I needed this: function add_admin_scripts( $hook ) { global $post; wp_register_script( ‘sectioned_page_script’, get_stylesheet_directory_uri() . ‘/js/sectioned_page.js’ ); if ( $hook == ‘post-new.php’ || $hook == ‘post.php’ ) { if … Read more
Unable to get the values for metaboxes for custom post type
There is no “fields” argument to add_meta_box(), which I assume is what you are using and not some code-bloat-ie helper function/class nonsense. And you’ve not identified a callback, which is the key. Create a callback and put your “warning” array in that, along with code to create your checkboxe/radio-boxes, or whatever you need. $wpar_meta_box = … Read more
you have to use “esc_attr” in case your value contains a quote for exemple <?php echo esc_attr(get_post_meta(…));?>
SOLVED!! There was a separate check for CPT needed for the saving to work. So the conditional code now stands at: function set_options() { parent::set_options(); global $pagenow; if ( isset( $_GET[‘post_type’] ) && $_GET[‘post_type’] == ‘session’ && ‘post-new.php’ == $pagenow || isset( $_GET[‘post’] ) && ‘session’ == get_post_type( $_GET[‘post’] ) && ‘post.php’ == $pagenow || … Read more
The key function and search key word is add_meta_box(). This function add additional meta boxes to a post type, also custom post type. See the codex for more about the parameters and also examples. You find also a lot of examples, how tos in the WWW and here on WPSE. A simple example to understand … Read more