• Resolved Hayden Ng

    (@haydenng664)


    Hi, I have created a custom post type called “Projects” and it has a parent and child relationship in it.

    However, there is this weird problem, creating a child for a parent project causes the child of the next parent project to disappear from Rest API. This is SUPER WEIRD, I couldn’t figure out why this happens, it doesn’t make sense.

    I could get the vanished child to re-appear by deleting the one that is not appearing in rest api, and then create a new child for it (using same page name and slug). But again, the next parent’s child disappears, and this goes on forever, when it reaches the last project, it loops back to the first project (the first project’s child disappear). Hence I will always be missing one children post.

    • This topic was modified 2 years, 4 months ago by Hayden Ng.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    So you have “Project A” and “Project B”

    You create a child for “Project A”, perhaps “Child A”.

    When you go and make “Child B”, for “Project B”, “Child A” disappears?

    That’s definitely sounding like a new one to me, so I don’t have any answer for it specifically. I am curious if something from a different plugin is causing things with REST API responses to get modified. CPTUI itself doesn’t do anything specific with the API outside of facilitate the registration fields for the post types and taxonomies.

    Thread Starter Hayden Ng

    (@haydenng664)

    It is something like that, let me correct some parts.

    It’s more of like it happens in a sequence.
    So let’s say I already have:
    – Project A with Child A
    – Project B with Child B
    – Project C with Child C
    When I create another Child A1 in Project A, the child from Project B would disappear. So i had to delete Child B and recreate it, but if I do that, child C will disappear! That is bizarre!

    I have checked my list of plugins, and everything is updated and seems normal. I also don’t understand why that happens and it is driving me crazyyy.

    Here is a list of plugins that I am using:

    • ACF to REST API
    • Advanced Custom Fields
    • Better REST API Featured Images
    • CF7
    • Contact Form CFDB7
    • Custom Post Type UI
    • Duplicate Post Page Menu & Custom Post Type
    • Enable Media Replace
    • Flamingo
    • Replace Internal Link URLs
    • Store file uploads for Contact Form 7
    • Updraft Plus
    • User Role Editor
    • WebP Express
    • White Label CMS
    • Wordfence
    • WP Add Mime Types
    • WP Headless
    • WP Mail SMTP
    • My site is a wordpress headless site btw.

    • This reply was modified 2 years, 4 months ago by Hayden Ng.
    • This reply was modified 2 years, 4 months ago by Hayden Ng.
    Thread Starter Hayden Ng

    (@haydenng664)

    I have tried deactivating the REST API related plugins like:
    – ACF to REST API
    – Better REST API Featured Images
    – WP Headless

    But still no luck, one children is always gonna be missing from my REST API. However, I also have categories assigned to that disappeared children, in the category REST API, it does show it!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Since it’s headless, I doubt a theme is contributing.

    By any chance are you able to disable EVERY plugin except CPTUI and see if the rest responses behave the same with the same issue?

    Also, just in case, is there anything in an mu-plugins folder that would be in wp-content ?

    Thread Starter Hayden Ng

    (@haydenng664)

    Hi, since it is headless, I actually opened a clean / empty theme for it, the theme literally has nothing on it.

    And I do not have a mu-plugins folder in my wp-content folder.

    I’ll try to create a staging site for it to test that out.

    Thread Starter Hayden Ng

    (@haydenng664)

    I have created a local site and disabled all plugins except CPTUI and also use on of the default theme (Twenty Twenty).

    The issue persists..

    Thread Starter Hayden Ng

    (@haydenng664)

    But it does seems like my rest api records tops out at 10 objects. So it means that there is actually a limit to rest api?

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    A lot of this feels more like issues within WP core handling, more than anything that CPTUI is don’t specifically, as we don’t have custom integrations within the REST API, outside of available parameters for register_post_type and register_taxonomy.

    Definitely very odd overall.

    I think the absolute max amount of results for REST API requests is 100, with 10 being default, much like other “posts per page” parameters. You can modify that with &per_page=100 parameters and change the value.

    Out of curiosity, what are the post type slugs you’re using?

    Thread Starter Hayden Ng

    (@haydenng664)

    I think you are right! When I modify the url to /projects/?page=2, I can see the vanished responses there!

    By any chance do you know how should I modify the post per page in wp core?

    I am using projects post type slug.

    Thread Starter Hayden Ng

    (@haydenng664)

    Oh I missed you there, so by appending the rest api url to have ?per_page=20 did the trick. Thanks so much for the insight!

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Whew, I’m glad that was the only issue, because I was out of ideas for whatever else may have been causing it ??

    Thread Starter Hayden Ng

    (@haydenng664)

    Thanks mate! Love your plugin btw, it is super nice to use.

    Have a nice day ahead mate. ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Child missing in REST API’ is closed to new replies.