Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#49623 closed defect (bug) (worksforme)

Hierarchical Custom Post Types do not show up in the REST API

Reported by: alanford123's profile alanford123 Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: reporter-feedback
Focuses: rest-api Cc:


When querying custom post types that are hierarchical, every non-parent item does not get returned.

To reproduce:

Create a custom post type, with

'hierarchical' => true,

Add some items, and set some to be child items.

Try to get a list of all the items using REST API, as such:


Observe that not all items get returned. All that are child items do not get returned.

It may have something to do with the url structure. Pages work as expected, and pages have all items with the same URL structure,


Regardless of being child or not.

Custom post types have a different url structure, where the items dont actually have id as their URL, but their slug.

CHild items have "parent-slug/child-slug"

Change History (3)

#1 @alanford123
4 years ago

Short update:

I observe the same behavior from the get_posts() function

#2 @TimothyBlynJacobs
4 years ago

  • Focuses javascript removed
  • Keywords reporter-feedback added; needs-patch removed
  • Version changed from 5.3.2 to 4.7

Hi @alanford123!

Welcome to trac and thanks for your ticket!

Could you try this with all plugins disabled and a stock WordPress theme? We have automated tests to verify that all posts are returned, including child posts, when doing a regular request to a hierarchical post type.

#3 @TimothyBlynJacobs
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Closing. Feel free to reopen if you can replicate this in a fresh WordPress install @alanford123.

Note: See TracTickets for help on using tickets.