🔵 other: Start page children block upgrade

This commit is contained in:
Keith Solomon
2025-09-26 08:46:53 -05:00
parent b6f14e6809
commit 7402826f3d
2 changed files with 42 additions and 26 deletions

View File

@@ -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
}
}

View File

@@ -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';