# Bricks Query Type: Child Pages of the Current Page

> Adds a "Child pages" query type to Bricks query loops that lists the subpages of the page being viewed, in menu order, for section overview pages.

- Type: PHP
- Runs: Run everywhere
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: bricks, query-loop, pages
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bricks-query-type-child-pages/

## Code

```php
add_filter( 'bricks/setup/control_options', function ( $options ) {
    $options['queryTypes']['wpide_child_pages'] = 'Child pages';

    return $options;
} );

add_filter( 'bricks/query/run', function ( $results, $query_obj ) {
    if ( ! is_object( $query_obj ) || 'wpide_child_pages' !== $query_obj->object_type ) {
        return $results;
    }

    $parent = get_queried_object_id();

    if ( ! $parent ) {
        return array();
    }

    return get_posts( array(
        'post_type'      => get_post_type( $parent ),
        'post_parent'    => $parent,
        'posts_per_page' => 50,
        'orderby'        => array( 'menu_order' => 'ASC', 'title' => 'ASC' ),
        'no_found_rows'  => true,
    ) );
}, 10, 2 );

add_filter( 'bricks/query/loop_object', function ( $loop_object, $loop_key, $query_obj ) {
    if ( is_object( $query_obj ) && 'wpide_child_pages' === $query_obj->object_type && $loop_object instanceof WP_Post ) {
        global $post;
        $post = $loop_object; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
        setup_postdata( $post );
    }

    return $loop_object;
}, 10, 3 );
```

## Notes

Choose "Child pages" as the query type on any looping element; dynamic data like {post_title} works inside it.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Bricks Query Type: Child Pages of the Current Page" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
