Once your private content is protected by our Protect Pages & Posts (PPP) plugin, those without permission won’t be able to access the content directly through its URL. They will be redirected to your “No Access” page instead.
However, the protected content will still display somewhere on your website such as your home page latest posts, Archives and Search results. This accidentally reveals your private content to unwanted users. That’s why we’ve developed a new feature which allows you to control the visibility of your protected pages and posts. In other words, you’ll be able to hide or decide where to display the protected content.
Requirement:
- Protect Pages & Posts (PPP) Gold 1.0.14 and greater
When a post is protected, it will no longer show up on these places by default:
- Front page latest posts
- Category pages
- Author pages
- Archives
- Recent posts
- Search results
- RSS Feeds
- Next & Previous on a single page or post
- Latest Posts, Recent Comments & Comments RSS Guttenberg widgets (WIP)
When it comes to WordPress protected pages, they will be excluded from:
- Front (home) page
- Search results
- Anywhere else it is listed via
get_pages
function
If you’re using the popular Yoast SEO plugin with the XML sitemaps enabled, we will provide another option to help you exclude your protected pages and posts from the XML sitemaps. As a result, they won’t be indexed by Google and other search engines anymore.
By default, protected content will be hidden from all users, regardless of their permissions.
Since version 2.0.3, you can hide the protected content from unauthorized users while allowing those who have correct permission to search and view them.
To do that, simply add the following custom codes to your (child) theme functions.php file.
add_filter( 'ppp_protected_posts_where', function ( $protected_ids ) { $ppp_function = new Prevent_Page_Pup_Function_Gold(); $result = array_filter( $protected_ids, function ( $protected_id ) use ( $ppp_function ) { return ! $ppp_function->check_pap_access_permission( $protected_id ); } ); return array_values( $result ); } );
Compatible with Flatsome theme
Flatsome theme uses a different method from WordPress to list the content in blog posts. That’s why your content might still display even when it’s already protected with PPP plugin.
To hide your private content built by Flatsome, add the following code snippet to your (child) theme’s functions.php file.
You can find the blog post’s ID by hovering over its title.
add_filter(
'the_posts',
function ( $posts ) {
if ( ! method_exists( 'Prevent_Page_Pup_Function_Gold', 'ppp_get_protected_ids_by_protected_posts' ) ) {
return $posts;
}
if ( ! is_singular() ) {
return $posts;
}
$post_id = get_the_ID();
$whitelisted_post_id = [ your-blog-post-id];
if ( ! in_array( $post_id, $whitelisted_post_id ) ) {
return $posts;
}
$function = new Prevent_Page_Pup_Function_Gold();
$protected_ids = $function->ppp_get_protected_ids_by_protected_posts();
if ( ! $protected_ids ) {
return $posts;
}
$posts = array_filter(
$posts,
function ( $post ) use ( $protected_ids ) {
return ! in_array( $post->ID, $protected_ids );
}
);
$posts = array_values( $posts );
return $posts;
}
);