Forked from bonny/ep_exclude_password_protected_pages.php
Last active
June 8, 2016 18:54
-
-
Save carasmo/769a02a056d477d61c9ffdc08267431f to your computer and use it in GitHub Desktop.
Automatically remove password protected page from wp_list_pages wherever this function is used such as the genesis sitemap.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** ====================================================================================== | |
* | |
* 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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment