[wp-trac] [WordPress Trac] #50108: Custom Post Type with public => false still generates/reserves title as permalink

WordPress Trac noreply at wordpress.org
Wed May 6 22:30:47 UTC 2020


#50108: Custom Post Type with public => false still generates/reserves title as
permalink
--------------------------+-----------------------------
 Reporter:  TBschen       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.4.1
 Severity:  minor         |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 A message with a permalink is still shown/generated after publishing a
 post of a custom post type with public=>false.


 **prerequisite**

 - Generate a basic custom post type like this

 {{{#!php
 <?php
 function teaser_post_type() {

         $labels = array(
                 'name'                  => 'My Teasers'
         );
         $args = array(
                 'label'                 => 'Teaser',
                 'description'           => 'it is a custom post type',
                 'labels'                => $labels,
                 'supports'              => array( 'title', 'editor',
 'custom-fields' ),
                 'hierarchical'          => false,
                 'public'                => false,
                 'show_ui'               => true,
                 'show_in_menu'          => true,
                 'menu_position'         => 5,
                 'menu_icon'             => 'dashicons-groups',
                 'show_in_admin_bar'     => true,
                 'show_in_nav_menus'     => false,
                 'can_export'            => true,
                 'has_archive'           => false,
                 'exclude_from_search'   => true,
                 'publicly_queryable'    => true,
                 'capability_type'       => 'page',
                 'show_in_rest'       => true,
         );
         register_post_type( 'teaser', $args );

 }
 add_action( 'init', 'teaser_post_type', 0 );
 }}}


 **issue**


 - create a post of the custom post type
 - type in a title and click on publish
 - it will ask if you're ready to publish, so click publish again
 - a new message appears: "%post_title% is now live" - below that is a
 generated permalink (domain.com/%post_type%/%post_name%/) (also "view
 post" and "copy link" buttons)

 The permalink leads to a 404 page which is correct, but the generated
 permalink and buttons should not happen (at least not be shown in the
 message), because the custom post type is public=>false.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50108>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list