[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
Wed Nov 29 04:24:08 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:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:  4.9
 Severity:  normal             |  Resolution:  invalid
 Keywords:                     |     Focuses:
-------------------------------+----------------------
Changes (by dd32):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Hi @antonv and welcome to Trac.

 The GUID field should not be treated as a URL to a entity, although
 currently the guid field is normally a short-url, there's no expectation
 that it's a resolvable URL to the item.

 The GIUD field could be set as a real UUID or the md5 of the post and
 still be valid.

 Anytime you need to access the URL to a post type, you should be using
 `get_permalink()`.

 I'm going to close this as invalid, as although it's being set to
 different defaults based on where the post is being made from, there
 shouldn't be any expectation from a code perspective that it's a real URL.

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


More information about the wp-trac mailing list