Saving CPT with featured image not possible
Support › MB Frontend Submission › Saving CPT with featured image not possibleResolved
- This topic has 17 replies, 3 voices, and was last updated 2 years, 5 months ago by
Stefan.
-
AuthorPosts
-
October 18, 2022 at 12:29 AM #38725
Stefan
ParticipantHi,
I have created a listing custom post type with various custom fields including an image upload field for the featured image. It used to work before, but whenever I try to add a new listing or update an existing one now by uploading a new image, it says: "Please correct the errors highlighted below and try again.".
When I don't try to upload a new image, I can save the listing. Any help on this issue is highly appreciated!
Console:
jquery.min.js?ver=3.6.0:2 Uncaught Error: Syntax error, unrecognized expression: # at se.error (jquery.min.js?ver=3.6.0:2:13639) at se.tokenize (jquery.min.js?ver=3.6.0:2:21650) at se.select (jquery.min.js?ver=3.6.0:2:22477) at Function.se [as find] (jquery.min.js?ver=3.6.0:2:7116) at S.fn.init.find (jquery.min.js?ver=3.6.0:2:25047) at new S.fn.init (jquery.min.js?ver=3.6.0:2:25536) at S (jquery.min.js?ver=3.6.0:2:1051) at e.value (validation.min.js?ver=5.6.7:29:8806) at HTMLFormElement.dispatch (jquery.min.js?ver=3.6.0:2:43064) at v.handle (jquery.min.js?ver=3.6.0:2:41048)
Thanks,
StefanOctober 18, 2022 at 11:15 AM #38730Long Nguyen
ModeratorHi,
Can you please share the page URL that has the frontend submission form? You can also try to deactivate all plugins except Meta Box, MB extensions and switch to the standard theme of WordPress (2022) and recheck this issue.
October 18, 2022 at 7:23 PM #38735Stefan
ParticipantHi,
Is there a way to send the page URL privately?
I have just deactivated all plugins except for Meta Box and Meta Box AIO and also changed the theme to the default 2022 WordPress theme. However, the issue still exists.
Best,
StefanOctober 18, 2022 at 11:06 PM #38739Long Nguyen
ModeratorHi,
You can share the private info via this contact form https://metabox.io/contact/
I will check it out.October 19, 2022 at 7:44 PM #38747Stefan
ParticipantHi Long Nguyen,
I have sent you the info via the contact form.
Best,
StefanOctober 19, 2022 at 10:02 PM #38749Long Nguyen
ModeratorHi,
You are using the validation
extension
to validate the extension of the image uploaded. But this rule only works with two field typesfile
andimage
while your field type isimage_upload
. I've changed the field Featured Image to the typeimage
then I can upload the image and submit the form as well.Please read more on the documentation https://docs.metabox.io/validation/
October 19, 2022 at 11:27 PM #38752Stefan
ParticipantThanks, you made my day!
October 19, 2022 at 11:36 PM #38753Stefan
ParticipantAnother follow-up question: I have removed the field validation and changed the field type to "Image Upload". The design of the field type looks so much better. 🙂
The image upload is working now! For the ID field, I tried _thumbnail_id and _thumbnail_id2, but unfortunately the uploaded image is not set as a featured image. Do you have any idea what the problem could be? You can test it at ourdomain/port/.
October 24, 2022 at 3:05 PM #38802Stefan
ParticipantHi,
Did you already have a chance to look at the featured image issue?
October 25, 2022 at 11:21 AM #38813Long Nguyen
ModeratorHi Stefan,
If you want to set the featured image by the custom field, please use the field type
single_image
. It saves one image ID to the database like the featured image of WordPress, the data saved of the field typeimage_upload
is different.
Read more on the documentation https://docs.metabox.io/fields/single-image/
https://docs.metabox.io/fields/image-upload/October 25, 2022 at 1:56 PM #38816Stefan
ParticipantHi Long Ngyuen,
Ok, I will use the
single_image
field type then. 🙂When I click on the "Add Media" button, nothing happens, but I get the following error message in the console:
media-views.min.js?ver=6.0.3:2 Uncaught TypeError: this.activateMode is not a function at media-views.min.js?ver=6.0.3:2:59600 at cn (embed-core.js?id=d52f4c09a24bf2889838:1:176662) at Function.so (embed-core.js?id=d52f4c09a24bf2889838:1:212941) at n._createModes (media-views.min.js?ver=6.0.3:2:59560) at n.initialize (media-views.min.js?ver=6.0.3:2:58969) at n.initialize (media-views.min.js?ver=6.0.3:2:79858) at n.initialize (media-views.min.js?ver=6.0.3:2:73428) at h.View (backbone.min.js?ver=1.4.1:2:14714) at n.constructor (wp-backbone.min.js?ver=6.0.3:2:2602) at n.constructor (media-views.min.js?ver=6.0.3:2:106836)
October 28, 2022 at 1:02 PM #38870Stefan
ParticipantDo you have any idea why the issue occurs?
October 28, 2022 at 6:09 PM #38873Long Nguyen
ModeratorHi,
After using the plugin https://wordpress.org/plugins/health-check/
to enable the troubleshooting mode (deactivate all plugins except Meta Box, MB AIO) and I can set the image for the field single_image as well. So it could be a conflicting issue with another plugin. You can try to deactivate all plugins except Meta Box, MB AIO then activate them one by one to find the culprit.November 4, 2022 at 10:18 PM #38959Stefan
ParticipantHi Long Nguyen,
After I removed the ConvertBox script from our website, the image upload via the single_image field works again. However, this image is still not set as a featured image.
I am storing the data in a custom table. Could this be the reason why it is not working? If so, how can I fix this problem?
It would be great if you could add a checkbox to the UI for the featured image. That would make the whole process much easier.
Best,
StefanNovember 6, 2022 at 10:52 AM #38967Peter
ModeratorHello Stefan
It is not possible to replace the featured image of the post if you save the custom field value to the custom table. Because the featured image of the post has the ID
_thumbnail_id
and save value to the default table of WordPresswp_postmeta
.You can save the field value to the default table instead of the custom table and see if it works.
-
AuthorPosts
- You must be logged in to reply to this topic.