Reputation:
Hye guys. I have wordpress template.php with listing custom pages. I need to exclude from my listing 2 pages. Is it possible? I'll give what I have maybe somebody knows an answer. Will be happy to solve this problem . THANKS!
WHAT I HAVE
<?php /* Template Name: # photography all archive */ get_header('photography'); ?>
<div class="base-content">
<div id="archive-thumbnails-listing" >
<?php $pages = get_pages(array('child_of' => 379,403)); ?>
<?php foreach ($pages as $page): ?>
<div class="thumb12">
<div class="thumb20"><a href="<?php the_permalink(); ?>">
<?php echo get_the_post_thumbnail($page->ID, 'full'); ?></a></div>
<div class="thumb19"><a href="<?php echo get_the_permalink($page->ID); ?>"><?php echo $page->post_title; ?></a></div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php
$args = array(
'exclude' => array(403), // exclude posts 379 and 403,
);
$pages = get_pages( $args ); ?>
<?php get_footer(); ?>
Upvotes: 0
Views: 837
Reputation: 16828
There are two ways that you can exclude pages using get_pages
The first is exclude
where you can provide an array or an integer of the post ID(s).
The second is exclude_tree
where you can provide the ID of a post and it will exclude any children of that post.
EX:
<?php
$args = array(
'exclude' => array(379,403), // exclude posts 379 and 403,
'exclude_tree' => 379 // exclude any child of post 379
);
$pages = get_pages( $args );
Codex: https://codex.wordpress.org/Function_Reference/get_pages
Upvotes: 1