Opened 3 years ago
Closed 2 years ago
#54965 closed defect (bug) (invalid)
Custom post type set as not public breaks media uploader functionality
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.9 |
Component: | Media | Keywords: | reporter-feedback |
Focuses: | Cc: |
Description
In 5.9 having a custom post type that is not public disables the media uploader option to select media files for 'Uploaded to this post' and does not attach any uploaded media files to that post.
Setting the values for either 'public' or 'publicly_queryable' to false when using register_post_type() causes this problem. If the values are set to true then the media uploader works as expected.
Change History (5)
#2
@
3 years ago
The only difference that I have here is that 'show_in_rest' is false.
<?php $labels = array ( 'name' => __ ('Content'), 'singular_name' => __ ('Block'), 'add_new' => __ ('Add New', 'empire'), 'add_new_item' => __ ('Add New Block'), 'edit_item' => __ ('Edit Bock'), 'new_item' => __ ('New Block'), 'view_item' => __ ('View Block'), 'search_items' => __ ('Search Blocks'), 'not_found' => __ ('Nothing found'), 'not_found_in_trash' => __ ('Nothing found in Trash'), 'parent_item_colon' => '' ); $args = array ( 'labels' => $labels, 'public' => false, 'publicly_queryable' => false, 'show_ui' => true, 'query_var' => false, 'show_in_rest' => true, 'rewrite' => false, 'capability_type' => 'post', 'hierarchical' => false, 'has_archive' => false, 'menu_position' => null, 'supports' => array ( 'title', 'editor', 'page-attributes' ) ); register_post_type ('customblock', $args);
#3
@
3 years ago
Thanks for the quick response @catacaustic!
I still can't seem to reproduce the issue after copying the snippet you posted. I also noted that your comment had show_in_rest
set to true
. I tested your snippet with both true
and false
for show_in_rest
. Both times, the Uploaded to this post
option showed the images I uploaded.
A couple of additional questions:
- What theme are you using?
- What plugins are installed and activated?
Test Report
Environment
Steps to reproduce
My CPT > Add New
.Upload
and proceed to upload an image.Media Library
.Filter Media
, selectUploaded to this post
.Publish
, thenPublish
.Media > Library
.Uploaded to
column for the image you uploaded, it should say(Private post)
with aDetach
link underneath.Results
Uploaded to this post
. ✅Uploaded to
column for the uploaded image says(Private post)
. ✅Hi @catacaustic, welcome to Trac!
I was unable to reproduce this issue. Can you let us know if any of the steps above are incorrect, or if there are any missing steps?