Created
February 17, 2013 03:18
-
-
Save Quasimo/4969937 to your computer and use it in GitHub Desktop.
WordPress加密文章可搜索的方法
This file contains hidden or 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
| add_filter( 'posts_search', 'include_password_posts_in_search' ); | |
| function include_password_posts_in_search( $search ) { | |
| global $wpdb; | |
| if( !is_user_logged_in() ) { | |
| $pattern = " AND ({$wpdb->prefix}posts.post_password = '')"; | |
| $search = str_replace( $pattern, '', $search ); | |
| } | |
| return $search; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment