$post->ID incorrect within meta box
Use the global variable $post. It is not specific to the Metabox, which is really just a portal for display. global $post; $PostId = $post->ID;
Use the global variable $post. It is not specific to the Metabox, which is really just a portal for display. global $post; $PostId = $post->ID;
So actually, for posts of the type attachment, you should use the edit_attachment (action) hook and not save_post_attachment: add_action( ‘edit_attachment’, ‘save_image_link’ ); // use edit_attachment //add_action( ‘save_post_attachment’, ‘save_image_link’ ); // not save_post_attachment Secondly, your meta box is not currently displaying the meta value, so you should display the value in the input field, and you … Read more
If someone wants to clean this up, all the better, but it gets the job done 🙂 If I understood you correctly, you need the ID for the user, yes? For more info on $wp_user_query check out this post which was a partial resource for me writing this code: http://www.mattvarone.com/wordpress/list-users-with-wp_user_query/ // List Users add_action(“admin_init”, “users_meta_init”); … Read more
The postbox class is hardcoded into the do_meta_boxes() function which is responsible for rendering meta boxes, and is not customizable via filters. Thus, I guess your best bet would be removing it using javascript. This should do it: functions.php add_action(‘admin_init’, ‘wpse_87339_admin_init’); function wpse_87339_admin_init() { wp_enqueue_script(‘wpse_87339_admin’, get_stylesheet_directory_uri() . ‘/js/admin.js’, array(‘jquery’)); } js/admin.js jQuery(document).ready(function($) { // Remove … Read more
The area is called the same. Just side, for sidebar. I found help for migration here: https://wordpress.org/gutenberg/handbook/extensibility/meta-box/ The PHP, for setting up your meta field to migrate, code needs some tweaks. First set in following as new argument on your meta field setup array( ‘__block_editor_compatible_meta_box’ => false, ) let’s you decide on next load of … Read more
I would seriously consider looking into the WPAlchemy metaboxes class. It does exactly what you are after and so much more. http://www.farinspace.com/wpalchemy-metabox/#have_fields_and_multi This class is so great that I am frankly shocked that there is not a lot more discussion about it. *If there is a better metabox class, I’d love to hear about it, … Read more
Get the attachment ID and convert to a post. From there the caption is stored on the post object. $thumb_img = get_post( get_post_thumbnail_id() ); // Get post by ID echo $thumb_img->post_excerpt; // Display Caption echo $thumb_img->post_content; // Display Description In your loop it would look like: <?php if($gallery) : ?> <?php foreach($gallery as $key => … Read more
You can add to figcaption on your front-end. <?php if ( !empty( $images ) ) { foreach ( $images as $image ) { $image_post = get_post($image); $caption = $image_post->post_excerpt; echo ‘<li class=”animated fadeIn”>’, ‘<figure>’, wp_get_attachment_image( $image, ‘post-full-width’ ), ‘<figcaption>’, $caption, ‘</figcaption>’, ‘</figure>’, ‘</li>’; } } ?>
I had to generate a bunch of extra code because I don’t think you’ve posted it all. In this case I don’t have scripts to add galleries so I tested it by pulling gallery data inside the post to populate the meta box. Each caption text field is generated per image then updated on post … Read more
I’m currently working on a theme framework and one of it’s classes is a custom category template class which does just what you are asking for: it adds a select field to the category edit screen that lets you select a template, just like with pages, and i just published it as a plugin Custom … Read more