Support Forum
I'm rebuilding an ACF site with MetaBox and I've run into an issue, but I might just be doing things wrong.
In ACF, I have a CPT with an image field. For the Field Name, I am able to use _thumbnail_id and any image uploaded to that field is automatically set as the Featured Image for that post.
In MetaBox, I have a CPT with a "Single Image" field. If I enter _thumbnail_id for the ID field, the Image (Add Media) doesn't even show up when editing the custom post. If I set the ID to anything else it functions as it should.
Am I going about this the wrong way?
Hello Mike,
Can you please deactivate all plugins except Meta Box, MB extensions, switch to a standard theme of WordPress (2022) and recheck this issue? And please share the code that creates the custom fields on your site, I will check it on my site.
Sorry for the delay. I have deactivated all plugins and the issue remains. I also tried a standard theme with no luck. For reference, this issue is on the back-end.. when editing a custom post type the "image" area is missing when using _thumbnail_id
Here is the code for my custom fields:
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Attribution', 'your-text-domain' ),
'id' => 'attribution',
'post_types' => ['attribution'],
'fields' => [
[
'name' => __( 'Author', 'your-text-domain' ),
'id' => $prefix . 'mh_attribution_author',
'type' => 'text',
'tooltip' => [
'icon' => '',
'position' => 'top',
'content' => 'Name the author or authors of the material in question. Sometimes, the licensor may want you to give credit to some other entity, like a company or pseudonym. In rare cases, the licensor may not want to be attributed at all. In all of these cases, just do what they request.',
],
],
[
'name' => __( 'Source URL', 'your-text-domain' ),
'id' => $prefix . 'mh_attribution_url',
'type' => 'url',
'tooltip' => [
'icon' => '',
'position' => 'top',
'content' => 'The URL of the material being attributed.',
],
],
[
'name' => __( 'Licensing Information', 'your-text-domain' ),
'id' => $prefix . 'mh_attribution_licensing',
'type' => 'textarea',
'required' => true,
'tooltip' => [
'icon' => '',
'position' => 'top',
'content' => 'How can I use it? You are using the material for free thanks to the CC license, so be sure to make a note of it. Try not to say the material is simply Creative Commons, because that says nothing about how the material can legally be used. Remember that there are six different CC licenses; which one is the material under? Name and provide a link to it, e.g. http://creativecommons.org/licenses/by/4.0/ for CC BY. → If the licensor included a license notice with more information, include that as well.',
],
],
[
'name' => __( 'Image', 'your-text-domain' ),
'id' => $prefix . '_thumbnail_id',
'type' => 'single_image',
'label_description' => __( 'test label description', 'your-text-domain' ),
'desc' => __( 'test input description', 'your-text-domain' ),
'required' => true,
'tooltip' => [
'icon' => '',
'position' => 'top',
'content' => 'If attribution is for an image/graphic, please add it here.',
],
],
[
'name' => __( 'Other Information', 'your-text-domain' ),
'id' => $prefix . 'mh_attribution_otherinfo',
'type' => 'wysiwyg',
'tooltip' => [
'icon' => '',
'position' => 'top',
'content' => 'When you accessed the material originally, did it come with any copyright notices; a notice that refers to the disclaimer of warranties; or a notice of previous modifications?',
],
],
],
];
return $meta_boxes;
}
I understand the issue, in the admin area, WordPress does not support displaying 2 fields with the same ID on a page. In the frontend, with the frontend submission form, it works properly.
In this case, I recommend removing the standard featured image section of WordPress to show the custom field created by Meta Box. If you create the CPT by Meta Box, you can go to Meta Box > Post Type > Edit the post type > Support tab > Disable option "Thumbnails".
This fix allowed the image upload to appear, but unfortunately it doesn't work the same as it did in ACF where it saves it as the post's featured image. For example, using this method with ACF, I can upload an image as part of my custom post type's image custom field using _thubnail_id and it automatically saves it into the featured image for that post so when using dynamic data I can just point at the featured image field.
However, in reality, maybe I'm overcomplicating things and should just stick with using the featured image as it is. My fear is that if I don't include it in the custom post type settings that the client will not know to add the featured image. The other option would be to just create my own field name and use that when setting up the dynamic data for the archive and single post type pages.
I'll decide on one of those two options but I definitely appreciate the support.
Thank you