By default, the title of your password protected content will still show up on various pages such as home page or search result. In some cases, you even want to hide these titles. So no one is aware of their existence except those who know the direct URLs.
Password Protect WordPress (PPWP) plugin gives you the ability to control your protected content’s visibility. You can not only password protect your private content but also hide its title and password form from different viewers.
Requirement:
- Password Protect WordPress Lite version 1.4.0 and greater
After activating the plugin, go to PPWP settings page, you will see the “Protected Content Visibility” option under General tab.
This option is disabled by default. If you turn it on, you will be suggested to hide your password protected posts in the following places:
- Home page or Front page
- Search results
- Category pages
- Author pages
- Archives
- Recent posts widget
- RSS Feeds
- Next & Previous
- Guttenberg widgets: Latest Posts, Recent Comments & Comments RSS (WIP)
When it comes to pages, our plugin allows you to hide them wherever they are listed via get_pages
function, such as:
- Front (home) page
- Search results
- Pages widget
- Navigation menu
Logic & Limitations
- If you’re using the popular Yoast SEO plugin with the XML sitemaps enabled, we will provide an option to help you exclude your password protected pages and posts from the XML sitemaps. As a result, they won’t be indexed by Google and other search engines anymore.
- While the protected content is hidden from everyone including those who have entered the right passwords, it’s still visible to all whitelisted users.
- If you stick a password protected post, it will still display on the home page.
- Currently, this feature only works with individual pages/posts protected by PPWP Free or PPWP Pro.
If you want to hide the content protected by the Category Protection option, simply add the following code snippet to your (child) theme’s functions.php file.
For PPWP Free
add_filter('ppw_custom_post_id_for_hide_protected_post', function($ids) { $is_protect = ppw_core_get_setting_type_bool_by_option_name( 'ppwp_is_protect_category', PPW_Category_Service::OPTION_NAME ); if ( ! $is_protect ) { return $ids; } $services = new PPW_Password_Services(); $protected_ids = $services->get_protected_post_ids(); $protected_categories = implode( ",", ppw_core_get_setting_type_array_by_option_name( 'ppwp_protected_categories_selected', PPW_Category_Service::OPTION_NAME ) ); $posts = get_posts( array( 'fields' => 'ids', 'category' => $protected_categories, ) ); foreach ($posts as $id) { $protected_ids[] = $id; } return $protected_ids; });