How to Password Protect Gallery built by PhotoMe Theme

With over 50+ pre-designed gallery and portfolio layouts, PhotoMe empowers photographers and artists to make their websites professional looking. This well-designed and user-friendly photography theme comes with a powerful drag and drop content builder that even WordPress rookies can utilize without hassle.

When it comes to password protection, only the content of the post/page will be protected by default while the gallery pages remain public to everyone. The PhotoMe theme doesn’t provide any hook for other plugins to implement such content protection

Therefore, to password protect the gallery, you have to modify their code by following the instructions below:

  1. Navigate to Appearance >> Theme Editor from your admin dashboard
  2. Open Gallery Page Template (gallery.php) file
  3. Add the following code snippet to line 15
if (post_password_required($post->ID)) {
      get_header();
      echo get_the_password_form();
      get_footer();
      return;
    }

Blog Portfolio David template

For the Blog Portfolio David template, add the following code snippet to line 76.

if ( $current_page_id && post_password_required( $current_page_id ) ) {
    echo get_the_password_form();
    get_footer();
    return;
}

Please note that the above custom code will be lost when you upgrade the theme.

Lasted updated on February 4, 2021