Support Forum
Support › Meta Box AIO › Field ID not being updated, data can't be pulled, can't use MB
Hello to all.
I am not PHP savvy so please bare with me. I am only beginning to use Metabox, along with Oxygen Builder that I love and have been using for 2 years now.
I am facing a simple but unsolved issue : after creating a Custom Post Type and A Field Group to work with it, I have been able to use the dynamic data in Oxygen properly. I then wanted to rename the Fields ID so as not to run into basic double-name conflicts (creating "thumbnail_ID" when it already exists for example) : I wanted to add a prefix to all my Field ID to be sure they would never conflict, and I have decided to replace all hyphens (-) to underscores () as recommended by Metabox.
After changing those IDs, things have gone hectic (in Oxygen Builder Dynamic Data insert) : old IDs still remain, although SOME of the new also appear, whereas A LOT of the newly named ones don't even show up... Even, stranger : SOMETIMES, the data can be retrieved, but by selecting one of the OLD names of an ID (after having changed that name, it shouldn't work/exist anymore, shouldn't it ???). Also, some Custom Post Types that I haven't updated the data retrieval query on, STILL get the data pulled... even after all purges (caches/databases/transients). But where does it get it from ???
How am I supposed to use Metabox after this ? The most basic dynamic data function is not working after a simple renaming of Field ID...
So, I have been looking how to clear all caches, many times, resigning shortcodes (Oxygen issue), even using WP Reset to clear transients (if ever this has any thing to do with it... : once again, I am not a code specialist), but this has no effect.
So I am left with a huge issue that does not allow me to continue developing my customer's website. Does anyone have any idea how to get these Field IDs to update and show for real, as I have named them, in Oxygen ?
Thank you in advance,
A.
PS : I have looked for hours on the web for answers, none found
PPS : I have activated Debug function of WP, says nothing...
Hi AnLip,
Thank you for reaching out.
I think this is a basic question. WordPress saves the custom fields in the table wp_postmeta
as a pair of meta_key
and meta_value
. But it does not support an option to delete the pair when you do not use it. It is still available on the database as well. So after you change the field ID which is the meta_key
, the old field ID can be still retrieved in the builder.
And there is no option to update the old value to the new field ID, you have to update the new field ID manually because it will be saved in the database as a new pair meta_key/meta_value
.
You can also follow this series for more information about custom fields https://metabox.io/how-wordpress-stores-custom-fields-database/
Hello Long, thank you for your quick response.
I figured out in the meantime that I needed to re-save the custom post type posts individually to erase the content of the old meta_keys. So by opening again the custom posts individually, the fields had become blank (after renaming their IDs), and by re-entering the data field by field, it would remove the old meta_keys no longer in use, and replace them with the new ones, and allow me to pull them. Another way round was to just copy/paste the meta_key ID without trying to find it in the list, as Oxygen allows that.
So now my fields are correctly populated, but I do have an issue with Single Images that do not want to come, I have no idea why. A broken image thumbnail pictogram shows (Chrome), no way to have it show up. Should I open another thread for this question ? Thank you in advance for your help.
A.
Hi,
Can you please share the code that creates the field single_image
? If you are using the Builder, please refer to this documentation https://docs.metabox.io/extensions/meta-box-builder/#getting-php-code
Hi,
This the PHP code generated through the WP back-office builder. All fields can be succesfully pulled, apart from the single image "dlc_media_photos_couverture".
FYI "dlc_media_photos_choix" corresponds to an Advanced Image field, where we can upload a gallery of images.
<?php
add_filter( 'rwmb_meta_boxes', 'your_prefix_function_name' );
function your_prefix_function_name( $meta_boxes ) {
$prefix = '';
$meta_boxes[] = [
'title' => __( 'Médias-Photos-Fields', 'your-text-domain' ),
'id' => 'medias-photos',
'post_types' => ['media-photo'],
'fields' => [
[
'name' => __( 'Titre de la galerie', 'your-text-domain' ),
'id' => $prefix . 'dlc_media_photos_titre',
'type' => 'text',
'label_description' => __( 'Titre à donner à la galerie (peut être le même que le titre de la publication)', 'your-text-domain' ),
'placeholder' => __( 'Concert de Marseille', 'your-text-domain' ),
'required' => true,
],
[
'name' => __( 'Image en couverture', 'your-text-domain' ),
'id' => $prefix . 'dlc_media_photos_couverture',
'type' => 'image_advanced',
'label_description' => __( 'Image à utiliser en couverture de la galerie', 'your-text-domain' ),
'max_file_uploads' => 1,
'required' => true,
'image_size' => 'medium',
'max_status' => false,
],
[
'name' => __( 'Choix d\'images à montrer', 'your-text-domain' ),
'id' => $prefix . 'dlc_media_photos_choix',
'type' => 'image_advanced',
'label_description' => __( 'Choisir la/les photo(s) à grouper dans cette galerie', 'your-text-domain' ),
'required' => true,
'max_status' => false,
],
[
'name' => __( 'Date de l\'évènement', 'your-text-domain' ),
'id' => $prefix . 'dlc_media_photos_date',
'type' => 'date',
'label_description' => __( 'Date de l\'évènement', 'your-text-domain' ),
],
[
'name' => __( 'Lieu', 'your-text-domain' ),
'id' => $prefix . 'dlc_media_photos_lieu',
'type' => 'text',
'label_description' => __( 'Lieu de l\'évènement', 'your-text-domain' ),
],
[
'name' => __( 'Crédits photographiques', 'your-text-domain' ),
'id' => $prefix . 'dlc_media_photos_credits',
'type' => 'text',
'label_description' => __( 'Personnes à créditer pour les photos', 'your-text-domain' ),
],
],
];
return $meta_boxes;
}
I get the same problem on another group of fields, where I can pull all the necessary data correctly, apart from the single image that doesn't show.
I recorded a short screen video of the problem, can I upload it here ? How ?
Hi,
I see the image field type is image_advanced
so you can try to use the Oxygen 3.9 Alpha 1 to test the compatibility with Meta Box. Read more on the Facebook Meta Box Group https://www.facebook.com/groups/metaboxusers/posts/909062386378073/
Use the component Gallery > click on the source Meta Box > select the field ID to show. Screenshot https://share.getcloudapp.com/Z4ujnD9G
If some fields do not show with Oxygen, you can send your feedback to the Oxygen developer team to fix the issue.
Hi,
Thanks for reply.
Actually the problematic field is not the image-advanced
type, but the single_image
type. It corresponds to the field I have named "dlc_media_photos_couverture". Can you help me with this one ?
I will, nevertheless try your suggestion concerning the other type of field.
Hi,
I see the field ID dlc_media_photos_couverture
with the field type image_advanced
in your code above.
[
'name' => __( 'Image en couverture', 'your-text-domain' ),
'id' => $prefix . 'dlc_media_photos_couverture',
'type' => 'image_advanced',
'label_description' => __( 'Image à utiliser en couverture de la galerie', 'your-text-domain' ),
'max_file_uploads' => 1,
'required' => true,
'image_size' => 'medium',
'max_status' => false,
],
It looks like the Oxygen builder does not support showing the image from the single_image
field value. So if you want to show the image with the field type single_image
, you can use the component Shortcode with this helper shortcode
[rwmb_meta id="single_image_fieldID" size="thumbnail"]
Get more details on this documentation https://docs.metabox.io/shortcode/