• We have a custom post type for knowledge-base articles on our intranet which we upload a lot of PDF’s to. I have just noticed when uploading a document or anything else within the edit page of the custom post type using ‘add media’ the files are not attached in the media library to that page, they all show as unattached. I can then manually attach them from the media library but thats not ideal.

    I cant seem to see anything in the custom post type setup that would prevent this from happening automatically, any ideas would be great?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Media get related to my CPT when I verified on my site. Here’s the relevant portion of my CPT registration data. Labels and capabilities omitted for brevity:

    		'public' => true,
    		'show_ui' => true,
    		'show_in_menu'=> true,
    		'show_in_nav_menus'=> true,
    		'show_in_rest'=> true,
    		'has_archive' => true,
    		'supports' => array(
    			'title',
    			'editor',
    			'page-attributes',
    			'comments',
    			'thumbnail',
    			'custom-fields',
    			'revisions',
    		 ),

    I know you specifically said you’re uploading media, but it’s probably worth mentioning anyway that adding media to a post that is already in the library will not relate it to that post. An existing unattached item in the library remains unattached even when it is inserted into a post, custom type or not.

    If your CPT uses similar registration data and media will still not relate to it, I’d suspect interference from a plugin or theme. Most of the registration data would have nothing to do with media attachment, but I’m unsure which would (if any), so I’m providing most of them.

Viewing 1 replies (of 1 total)
  • The topic ‘Files uploaded on custom post type page not “attached” to the page’ is closed to new replies.