Wordpress: Hide protected post on Recent Post widget
Aug 28, 2009 Programming
I am using the WP Hide Post and I didn’t like that the password protected posts are displayed on the front Recent Post section.
I added 2 small php code and now there are no protected posts on Recent Post.
The way is:
1. Change wp-includes/default-widgets.php file
$r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1)); |
to
$r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1, 'post_password'=>'hide' )); |
2. Change wp-includes/query.php file
if ( !isset($q['caller_get_posts']) ) $q['caller_get_posts'] = false; |
to
if (!current_user_can('manage_options') && isset($q['post_password'])=='hide') $where .= " AND ($wpdb->posts.post_password = '') "; if ( !isset($q['caller_get_posts']) ) $q['caller_get_posts'] = false; |
Related posts:




Leave a Reply