Created
February 17, 2023 16:37
-
-
Save wpflames/f506586f843ad2b6d4ad133b89466e53 to your computer and use it in GitHub Desktop.
Display child pages with featured images in cards
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.card { | |
background: transparent; | |
box-shadow: var(--shadow-1); | |
border: 1px solid var(--grey-100); | |
color: var(--grey-800); | |
transition: var(--ease); | |
&:hover .card-figure-overlay { | |
opacity: 1; | |
} | |
&:hover .card-title { | |
background: var(--primary); | |
} | |
&:hover .card-readmore { | |
background: var(--primary); | |
} | |
&-link { | |
text-decoration: none; | |
display: block; | |
color: var(--white) !important; | |
} | |
&-figure { | |
position: relative; | |
margin: 0; | |
overflow: hidden; | |
&-overlay { | |
background: var(--green-overlay); | |
height: 404px; | |
width: 100%; | |
position: absolute; | |
top: 0; | |
left: 0; | |
opacity: 0; | |
z-index: 2; | |
} | |
} | |
&-img { | |
margin-top: 0 !important; | |
margin-bottom: -6px !important; | |
position: relative; | |
} | |
&-title { | |
background: var(--grey-900); | |
color: var(--white); | |
font-weight: normal; | |
font-size: 1.4rem; | |
font-weight: 600; | |
text-align: center; | |
padding: 10px; | |
} | |
&-text { | |
margin: 20px; | |
} | |
&-readmore { | |
background: var(--grey-900); | |
border-radius: 5px; | |
color: var(--white) !important; | |
display: block; | |
margin: 20px; | |
padding: 5px 15px; | |
text-align: center; | |
text-decoration: none; | |
width: 120px; | |
} | |
} | |
.page.iskolaink { | |
.card-link { | |
margin: 0; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
global $id; | |
$args = array('child_of' => $id); | |
$child_pages = get_pages($args); | |
?> | |
<div class="grid-3"> | |
<?php if (!empty($child_pages)): ?> | |
<?php foreach ($child_pages as $key => $page_item): ?> | |
<div class="card"> | |
<a class="card-link" href="<?php echo esc_url(get_permalink($page_item->ID)); ?>"> | |
<figure class="card-figure"> | |
<span class="card-figure-overlay"></span> | |
<?php echo get_the_post_thumbnail($page_item->ID,'gallery'); ?> | |
</figure> | |
<div class="card-title"><?php echo $page_item->post_title ; ?></div> | |
</a> | |
</div> | |
<?php endforeach ?> | |
<?php endif ?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment