Select parent page and all its child page but exclude one specific child page
Hi everyone hope all is good. I need some suggestion. I need to select parent page and all its child page but exclude one specific child page. can you please tell me how can i exclude specific child ?
```// Store Only Show For the Registered Users
function woocommerce_store_private_redirect() {
global $post;
if (
! is_user_logged_in()
(is_woocommerce() || is_cart() || is_checkout() || is_product_category() || is_product_tag() || is_product() || is_tree(64) )
) {
// feel free to customize the following line to suit your needs
wp_redirect( site_url('mein-konto/') );
exit;
}
}
add_action('template_redirect', 'woocommerce_store_private_redirect');
function is_tree($pid) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
$pages = get_posts([
'post_type' = 'page',
'posts_per_page' = -1,
'post_parent' = $pid, // the parent id you want the children from
'post__not_in' = [4419] // the id you want to exclude
]);
if(is_page() $pages)
return true; // we're at the page or at a sub page
else
return false; // we're elsewhere
};
Topic development-strategy php Wordpress
Category Web