[wp-trac] [WordPress Trac] #42727: wp_insert_post() for custom post types generates wrong URL in the field wp_posts->guid

WordPress Trac noreply at wordpress.org
Tue Nov 28 11:12:12 UTC 2017


#42727: wp_insert_post() for custom post types generates wrong URL in the field
wp_posts->guid
-------------------------------+-----------------------------
 Reporter:  antonv             |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  4.9
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 here is the example snippet
 {{{#!php
 <?php
 $newpost_args = array(
    "menu_order" => $new_menu_order,
    "post_parent" => $post_parent_id,
    "post_status" => ( ('publish' == $post_status) &&
 !current_user_can('publish_posts') ? 'pending' : $post_status ),
    "post_title" => $one_new_post_name,
    "post_type" => "songs",
     );
     $new_post_id = wp_insert_post($newpost_args);
 }}}

 the wp_posts->guid is now set to www.example.com/songs/parent-slug/child-
 slug

 All good and well till you change the slug in the Edit or Quick Edit and
 the post is no longer reachable and returns 404!

 If I create the same child post in Edit
 then wp_posts->guid is set to www.example.com/?post_type=songs&;p=1234

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


More information about the wp-trac mailing list