Administrator cannot see private content

Private Content Private content is published only for your eyes, or the eyes of only those with authorization permission levels to see private content. Normal users and visitors will not be aware of private content. It will not appear in the article lists. If a visitor were to guess the URL for your private post, … Read more

Assign a username and password to specific users

Yes, there are several possible ways to do this. The easiest method is probably to use Basic HTTP Authentication using a .htaccess and .htpasswd file. Here’s a site that will generate these for you. You can create separate usernames/passwords and then drop these files in the private folder. There are several guides and tutorials for … Read more

Custom get_the_password_form

If you look at the source code of the get_the_content() function which retrieves the post content, you’d see the following conditional: if ( post_password_required( $post ) ) return get_the_password_form( $post ); And in the get_the_password_form() function, there’s a filter you can use to customize the HTML of the default password form: return apply_filters( ‘the_password_form’, $output … Read more

Will ‘private’ status prevent Woocommerce products to be indexed by search engines?

If you are using the default WordPress method of marking a post/page private, NO. This only prevents that post/page content from being viewable. Google (and other search bots) will not find private pages. Only logged in blog Editors and Administrators can see Private pages. So, while WordPress will not add the meta to block bots, … Read more

How to remove private posts from RSS feeds?

The same way you would change which posts WP shows on any other screen, pre_get_posts! If you ever see WP pull in posts, and want to modify what it fetches from the DB, use the pre_get_posts filter E.g. something similar to this: add_action( ‘pre_get_posts’, function( \WP_Query $query ) { if ( !$query->is_feed() ) { return; … Read more

Forcing two or more custom post type to be private

You can add multiple compared condition variable in single if condition using logical OR operator. For more knowledge of Logical condition click function force_type_private($post) { if ($post[‘post_type’] == ‘my_post_type1’ || $post[‘post_type’] == ‘my_post_type2’) { $post[‘post_status’] = ‘private’; } return $post; } add_filter(‘wp_insert_post_data’, ‘force_type_private ‘);

Check the stored / cached WP_Query with transients on post change

Use the save_post hook to check if a post that is being saved is a portfolio page and reset the transient. add_action( ‘save_post’, ‘reset_portfolio_transient’, 10,3 ); function reset_portfolio_transient( $post_id, $post, $update ) { // Only set for portfolio post_type if ( ‘portfolio’ !== get_post_type($post) ) { return; } // delete old tranisent delete_transient( ‘randomizeProfiles’ ); … Read more