[wp-trac] [WordPress Trac] #25136: url_to_postid() fails but get_page_by_path() works, on a Woocommerce page

WordPress Trac noreply at wordpress.org
Sun Aug 25 03:24:29 UTC 2013


#25136: url_to_postid() fails but get_page_by_path() works, on a Woocommerce page
--------------------------+------------------------------
 Reporter:  adiant        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:  3.6
 Severity:  normal        |  Resolution:
 Keywords:                |
--------------------------+------------------------------

Comment (by SergeyBiryukov):

 `get_page_by_path()` specifically looks for a page with the provided slug,
 while `url_to_postid()` only returns the post/page ID if it resolves to a
 singular entity (which is not the case for a post type archive):
 [source:tags/3.6/wp-includes/rewrite.php#L368].

 This seems like expected behaviour to me, I don't see a bug here. I'd
 suggest using `get_page_by_path()` if it makes more sense in your
 situation.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25136#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list