[wp-trac] [WordPress Trac] #17609: 'View post' link shown even when post type can't be viewed on the front-end

WordPress Trac noreply at wordpress.org
Thu Aug 20 18:39:54 UTC 2015


#17609: 'View post' link shown even when post type can't be viewed on the front-end
-------------------------------+-----------------------
 Reporter:  scribu             |       Owner:
     Type:  defect (bug)       |      Status:  assigned
 Priority:  normal             |   Milestone:  4.4
Component:  Posts, Post Types  |     Version:  2.9
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |     Focuses:
-------------------------------+-----------------------
Changes (by wonderboymusic):

 * owner:  nacin =>
 * status:  reopened => assigned


Comment:

 I **think** [attachment:17609.3.diff 17609.3.diff] handles this well and
 rewrites the way messages are composed (an improvement IMHO)

 `publicly_queryable` means something different for `_builtin` types. To
 determine if a post type is viewable, we should do this check:

 {{{
 $post_type->publicly_queryable || ( $post_type->_builtin &&
 $post_type->public )
 }}}

 This handles every case well in my testing. To test, make a custom post
 type like so:

 {{{
 add_action( 'init', function () {
         register_post_type( 'tacos', [
                 'public' => true,
                 'publicly_queryable' => false,
                 'labels' => [
                         'name' => 'Tacos'
                 ]
         ] );
 } );
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/17609#comment:47>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list