WordPress.org

Ready to get started?Download WordPress

Forums

Types - Custom Fields and Custom Post Types Management
[resolved] Child pages of custom post type not (6 posts)

  1. _td
    Member
    Posted 2 years ago #

    I set up a custom post type of Event. In that post type, I specified that Pages could be a child of Event, since I did have a Page that I wanted to associate with that Event (and only Page per Event).

    On my Page edit screen, I was able to properly select the Event that I wanted to be the parent. And also on my Event page I can see that the child page is properly filled in the "Fields" area (where other children of the Event post are).

    However, now I'm trying to access these in a plugin I've written. I have my post ID for my event, and I'm trying to get the children of that Event like so:

    $params = array(
    		'post_parent' => 16,
    		'post_type' => 'page'
    	);
    
    	$survey_page = get_children($params);

    This always returns empty. And if I check in the database, I see that for my child post, there isn't anything the post_parent field.

    So how are these relationships getting stored and is there a different function I should be calling to get the children of a custom post type?

    http://wordpress.org/extend/plugins/types/

  2. Srdjan
    Member
    Plugin Author

    Posted 2 years ago #

    Types actually don't use WP's relation parent->child but own defined relation.

    Try while in loop:
    $children = types_child_posts('page');

    or
    $children = wpcf_pr_post_get_has($parent_post_id, 'page');

  3. _td
    Member
    Posted 2 years ago #

    OK, thank you! I figured I had to call a different function to get a that. Is there documentation anywhere that has those functions?

  4. Srdjan
    Member
    Plugin Author

    Posted 2 years ago #

  5. AmirHelzer
    Member
    Plugin Author

    Posted 2 years ago #

    Need any more help?

  6. _td
    Member
    Posted 2 years ago #

    I think I'm good. Thanks Amir!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic