Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a simple function that adds a couple of pages to the users website when they activate my plugin. Actually there are many plugins out there that generate custom pages for the user, plugins like woocommerce do this.

Question: If the user does not have a menu assigned to their theme, many times the theme reverts back to simply showing a list of pages, I think by using the wp_list_pages() function.

Is there a way of automatically excluding my dynamically created pages from wp_list_pages()?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

If you don't want them to ever be listed (using wp_list_pages at least) then you could hide them using a filter

add_filter('wp_list_pages_excludes', 'my_page_excludes');
function my_page_excludes() {
    // the array should contain the page ids you want to exclude
    return array(1,6,7,12);
}

This will stop them from displaying in anything that lists pages using WordPress template functions - including widgets etc. If the user may ever want them to be visible then they'd have to use a custom menu - or you'd have to provide an option to display them.

share|improve this answer
    
absolutely perfect! –  shawn Jan 31 '13 at 5:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.