Initial commit to github
This commit is contained in:
26
views/blocks/page-children/block.json
Normal file
26
views/blocks/page-children/block.json
Normal file
@@ -0,0 +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
|
||||
}
|
||||
}
|
||||
0
views/blocks/page-children/page-children.css
Normal file
0
views/blocks/page-children/page-children.css
Normal file
37
views/blocks/page-children/page-children.php
Normal file
37
views/blocks/page-children/page-children.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Page Children block
|
||||
*
|
||||
* @package BasicWP
|
||||
*/
|
||||
|
||||
namespace BasicWP;
|
||||
|
||||
// Retrieve the current page ID and its children
|
||||
$currentPageId = get_the_ID();
|
||||
$currentPageChildren = get_pages( array( 'child_of' => $currentPageId ) );
|
||||
|
||||
// Set classes
|
||||
$classes = 'page-children';
|
||||
|
||||
// Set wrapper attributes
|
||||
if ( ! $is_preview ) {
|
||||
$wrapper = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
||||
} else {
|
||||
$wrapper = 'class="' . $classes . '"';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( ! empty( $currentPageChildren ) ) : ?>
|
||||
<section id="page-children" <?php echo wp_kses_post( $wrapper ); ?>>
|
||||
<ul>
|
||||
<?php foreach ( $currentPageChildren as $child ) : ?>
|
||||
<li class="page-child">
|
||||
<a href="<?php echo esc_url( get_permalink( $child->ID ) ); ?>">
|
||||
<?php echo esc_html( $child->post_title ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user