Home Forums Feature Requests New feature for posts with post_parent=0


New feature for posts with post_parent=0

  • Hi everyone.
    I have a custom post type where each post has children under it (like pages do).
    I was just making some fields and i came accross the following needs:
    – post object: It would be handy if we could set to show only the ones with post_parent=0. So i would like to be able to fetch only the “main” posts for a custom field with type: post object.
    – when you set a new Field group: In the Location -> Rules it would be nice to be able to set this group only for posts with post_parent=0 or for posts with post_parent>0

    thanks! Great plugin

  • The first part can be done using this filter

    The second part requires creating a custom location rule I have some example custom location rules here There’s not one that is specifically for what you want. If you dig around in ACF and find the page type location rules you can pretty much copy most of what you need from ACF for use with your custom post type. Although, I just dug around in ACF and it seems that the Page Type location rule should work for parent/child no matter what post type you use it on (unless I’m missing something)

  • Thanks for the quick reply!

    The first part is now solved with the filter you mentioned.

    For the second part, the page parent will only return a list of my pages. If it also returned the ‘0’ value then i could use this. I will check the links you sent and see what i can manage.
    Still it would be nice to also have a post parent in the location rules or also include the ‘0’ in page parent.

    thank you.

  • This does not work?
    Page Type is equal to Parent Page (has children)

    I already know that it’s not likely that custom location rules will be added for custom post types, at least not by the developer. So it the above does not work your only real option is to create a custom location rule.

    And I do have an example that will do something similar here that I’m sure can be made to work with a few tweaks.

  • Thanks!

    I hadn’t noticed that “page type” has these options.
    this solved it.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘New feature for posts with post_parent=0’ is closed to new replies.