I’m trying to hide details about a child page when I’m on the siblings and it’s parent page and I don’t know how.
What I made is exclude the child page details when I’m on it. I want to exclude the details that I’m geting about that page when I’m on it’s parent or siblings too.
Logic:
if current page is parent page, exclude children
if current page is not parent page, exclude children pages with meta value 1
Can anyone help me with this?
My code:
<?php
$current_page_id = get_the_ID();
$args = array( 'post_type'=>'page',
'meta_key' => 'show_info',
'meta_value'=> 1,
'exclude' => $current_page_id );
$pages = get_posts($args);
?>
<div class='custom_pages_container'>
<h1 class="titlefade" style="font-size: 1.6em;">Usefull informations</h1>
<?php foreach($pages as $page){ ?>
<div class='custom_wrapp'>
<div class='img_despre_bp'>
<a target='blank' href='<?php echo get_permalink($page->ID); ?>'>
<?php echo get_the_post_thumbnail($page->ID, 'homepage-thumb2'); ?></a>
</div>
<div class='despre_desc' style='text-align: left;'>
<a target='blank' href='<?php echo get_permalink($page->ID); ?>'><h1 style="font-size: 1.6em;"><?php echo $page->post_title; ?></h1></a>
</div>
</div>
<?php } ?>
</div>