diff --git a/views/blocks/page-children/block.json b/views/blocks/page-children/block.json index c188d3f..ff322ae 100644 --- a/views/blocks/page-children/block.json +++ b/views/blocks/page-children/block.json @@ -1,26 +1,26 @@ { - "name": "acf/page-children", - "title": "Page Children", - "description": "Block to display children of curent page.", - "style": [ - "file:./page-children.css" - ], - "category": "vdi-block", - "icon": "block-default", - "keywords": [ - "page-children" - ], - "acf": { - "mode": "preview", - "renderTemplate": "page-children.php" - }, - "supports": { - "align": false, - "anchor": false, - "color": false, - "html": false, - "jsx": false, - "mode": false, - "multiple": false - } + "name": "acf/page-children", + "title": "Page Children", + "description": "Block to display children of curent page.", + "style": [ + "file:./page-children.css" + ], + "category": "vdi-block", + "icon": "block-default", + "keywords": [ + "page-children" + ], + "acf": { + "mode": "preview", + "renderTemplate": "page-children.php" + }, + "supports": { + "align": false, + "anchor": false, + "color": false, + "html": false, + "jsx": false, + "mode": false, + "multiple": false + } } diff --git a/views/blocks/page-children/page-children.php b/views/blocks/page-children/page-children.php index b4fc7b9..b63bc89 100644 --- a/views/blocks/page-children/page-children.php +++ b/views/blocks/page-children/page-children.php @@ -8,8 +8,24 @@ namespace BasicWP; // Retrieve the current page ID and its children -$currentPageId = get_the_ID(); -$currentPageChildren = get_pages( array( 'child_of' => $currentPageId ) ); +$parentId = get_queried_object_id(); + +// Children: direct descendants only +$children = get_posts( + array( + 'post_type' => 'page', + 'post_status' => 'publish', + 'posts_per_page' => -1, + 'orderby' => array( + 'menu_order' => 'ASC', + 'title' => 'ASC', + ), + 'order' => 'ASC', + 'post_parent' => $parentId, + 'fields' => 'all', + 'no_found_rows' => true, + ) +); // Set classes $classes = 'page-children';