Question: I am looking for a way to create a Photo Post type. Basically a post that is a title and a single image. Where I am getting stuck is the actual attaching an image to a post. I would like to have an image upload field in a metabox. I followed this [guide](http://austinpassy.com/2010/03/creating-custom-metaboxes-and-the-built-in-uploader/). I am able to see the WP upload box and I upload an image from my machine and click "Insert into Post". Then I publish the post. I don't know if the image is actually attached to that post though. I see the post in the database as well as the image as an "attachment" post\_type.

Is this a good direction to go in if all I want is a simple attach a single image to a post along with a title?

Also, is there any way to simplify the media upload lightbox just for a certain post type? (Making it so the user doesn't need to know to click "Insert into Post" instead of "Save All Changes"?

Answer: 
Your above function tests whether a page *is* a child page of some other page, not whether it has children.

You can test for children of the current page like so:

```
function has_children() {
    global $post;

    $children = get_pages( array( 'child_of' => $post->ID ) );
    if( count( $children ) == 0 ) {
        return false;
    } else {
        return true;
    }
}

```

Further reading:

* [wp codex: get\_pages](http://codex.wordpress.org/Function_Reference/get_pages)
* [php manual: count](http://php.net/manual/en/function.count.php)
Here is version for any post type, in case if you are using custom post type

```
function has_children($post_ID = null) {
    if ($post_ID === null) {
        global $post;
        $post_ID = $post->ID;
    }
    $query = new WP_Query(array('post_parent' => $post_ID, 'post_type' => 'any'));

    return $query->have_posts();
}

```