$page = get_page_by_title('About');
wp_list_pages('exclude='.$page->ID);
Thankyou. It works, but I forgot to mention that there is more than one page to exclude.
I have studied the codex to see how to put them in an array but no luck.
So far I have this:
$page = get_page_by_title (array(
'About'),
('Privacy'),
('Disclaimer')
));
But it only excludes the first page ‘About’.
Thank you.
You’d have to get each value individually.
OK. I have got the values individually like this:
$page1 = get_page_by_title ('About');
$page2 = get_page_by_title ('Services');
$page2 = get_page_by_title ('Privacy');
and they all work. For example:
wp_list_pages('exclude='.$page1->ID);
wp_list_pages('exclude='.$page2->ID);
wp_list_pages('exclude='.$page3->ID);
But I cannot seem to combine them so that a single instance of wp_list_pages excludes all of them.
I know this is no where near right, but the result I am seeking is:
wp_list_pages('exclude='.$page1->ID, .$page2->ID, .$page3->ID);
Thanks for your help so far. Sorry not to have figured this.
$args = 'exclude=' . $page1->ID . ',' . $page2->ID . ',' . $page3->ID
wp_list_pages($args);
Thank you!
For others seeking this solution (provided by MichaelH):-
The code for excluding pages when you know the Title but not the ID. The following is an example excluding three pages from the menu.
<?php
$page1 = get_page_by_title ('About');
$page2 = get_page_by_title ('Services');
$page3 = get_page_by_title ('Privacy Policy');
wp_list_pages('exclude=' . $page1->ID . ',' . $page2->ID . ',' . $page3->ID);
?>
thanks it working ……… but can any one help it by using array
Is there any way to make it so that when you exclude a page it also excludes all the sub-pages under it? Rather than having to put the sub-pages in manually?
Hi,
I have a question related to excluding pages from nav bar but not excluding from page source. Because all the exclude option does is make the page private and I don’t want the page to be private
any suggestions