Skip to content

Commit

Permalink
added subpages shortcode
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjorn Zschernack committed Nov 20, 2023
1 parent ec008b9 commit df24bd0
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
13 changes: 12 additions & 1 deletion includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ function getPostTypeGrid($atts){
return $content;
}

add_shortcode( 'grid', 'getPostTypeGrid' );
add_shortcode( 'grid', 'getPostTypeGrid' );



function getSubpages($atts){
ob_start();
$content .= get_template_part('template-parts/shortcodes/grid','',$atts);
$content .= ob_get_clean();
return $content;
}

add_shortcode( 'subpages', 'getSubpages' );
8 changes: 8 additions & 0 deletions template-parts/pages/subpage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


<div class="single-post bg-white">

<div class="single-post-content d-flex flex-column justify-content-center align-items-center">
</div>
</div>
32 changes: 22 additions & 10 deletions template-parts/shortcodes/grid.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
<div class="container-fluid p-0">
<div class="row">
<?php
<?php if( isset ($args['headline'])): ?>
<?php endif; ?>

$grid = 4;
<?php
$subpages = get_pages(
array(
'parent' => $post->ID,
'posts_per_page' => '-1'
)
);

if(isset($args['grid'])) :
$grid = $args['grid'];
endif;

?>

?>
</div>
</div>

<div class="posts-grid p-0 w-100">

<?php

foreach ($subpages as $subpage) {

get_template_part('template-parts/pages/subpage','', $subpage);
}

?>
</div>

0 comments on commit df24bd0

Please sign in to comment.