Automatically remove password protected page from wp_list_pages wherever this function is used such as the genesis sitemap.
/** ======================================================================================
*
* Automatically Exclude Password Protected Pages
*
* Kudos: https://gist.github.com/bonny/5772054
* The original (linked above) uses an argument:
* wp_list_pages('title_li=&post_type=faqs&echo=0&exclude_password_protected=1')
*
======================================================================================= */
function ca_exclude_password_protected_pages($pages, $r) {
if ( is_admin() ) return;
for ( $i = 0; $i < sizeof( $pages ); $i++ ) {
if ( post_password_required( $pages[ $i ] ) ) {
unset( $pages[ $i ] );
}
}
return $pages;
}
add_filter( 'get_pages', 'ca_exclude_password_protected_pages', 10, 2 );