Media Post Parent Not Attached On CPT With Certain Field Types

Support General Media Post Parent Not Attached On CPT With Certain Field Types

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33951
    Armand MorinArmand Morin
    Participant

    If you remember, I've gone over this issue previously.

    This is a problem and the solution you suggested are valid if the media has a post parent. The issue is the post parent is not attached if you are using a custom post type with certain types of fields.

    I have created a video and you can replicate this issue yourself.

    Here is the video please let me know about this issue. I think you'll see it clearly.

    https://www.youtube.com/watch?v=jDP8SNrsAJ0

    #33957
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thanks for getting in touch.

    I've made a short screen record to test with two field types file_upload and video
    https://monosnap.com/file/3JgsffGCssTcJwjgHWsEAQqi8gOPhj

    The problem is, the field has the setting 'multiple' => true will save the attachment IDs in the database following the format ID1, ID2, ID3, ... and it might not work as the single_image field which saves only one attachment ID like the standard field featured image. That means the second file uploaded will not be attached to the post as on my testing case.

    I see you are using the WP function get_attached_media() to get the media attached to the post, and you can use the helper function rwmb_meta() instead of this function to get the media (attachment) ID. Read more on the documentation https://docs.metabox.io/fields/file-upload/#template-usage

    #33964
    Armand MorinArmand Morin
    Participant

    Thank you for the response. After watching your video and seeing the video and images attached, I started doing some testing.

    The reason is they are not attaching is simply because in supports if 'Thumbnail' is not added, most files or images will not be attached to the post.

    Once I added 'Thumbnail' in supports in the custom post type, everything is not attached. I'm not sure if this is a WordPress thing or Metabox, I'm thinking WordPress

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.