Support » How-To and Troubleshooting » wp_list_pages won’t exclude pages
8 years, 3 months ago
I am trying to control the list of pages dispayed in my main menu. I have tried to use the ‘exclude’ and ‘include’ statements in wp_list_pages but they don’t seem to work. The generic code is:
‘<?php wp_list_pages(‘title_li=&depth=0&sort_column=menu_order’); ?>
I have tried changing it to this, but nothing happens on the page:
‘<?php wp_list_pages(‘exclude=10&title_li=&depth=0&sort_column=menu_order’); ?>
I have also tried this, but then only the link to ‘Home’ appears:
‘<?php wp_list_pages(‘include=2&title_li=&depth=0&sort_column=menu_order’); ?>
Can anyone tell me what I’m doing wrong?
what is the site url?
8 years, 2 months ago
Looks like the code I posted is a bit messed up. Can anyone make sense of it?
Look down at the bottom of the screen, below the editing box. See where it says “Put code in between backticks.”? That means you too.
The backtick is right below the tilde ~ on your keyboard.
7 years, 8 months ago
I’m also trying to exclude pages from being listed in my menu bar. I found a tutorial that says to type this…
<?php wp_list_pages('exclude=17,38' ); ?>
…(the number being page IDs), but my code looks like this:
$pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0');
$pages = preg_replace('%<a ([^>]+)>%U','<a $1><span>', $pages);
$pages = str_replace('</a>','</span></a>', $pages);
Where should I enter the “exclude” text?