Best WordPress Theme & Plugin For Photographers

Imagely Blog

Digital Photography Tips, Tutorials and Resources
Padlock sitting on a laptop keyboard, representing a password protected WordPress gallery

How To Hide Password Protected Galleries From Displaying In Recent Posts

Written By: author avatar Chris Christoff
author avatar Chris Christoff
    

Many Imagely users take advantage of protecting their galleries with passwords. This is done using the WordPress feature for password protection of posts and pages.

A use case for doing so might be implementing a proofing gallery for a client, or a private gallery of family photos.

By default, if you create a blog post with password protection it will wind up in your blog archives, on your main blog page and even in the Recent Posts widget. That is not ideal as it can confuse your website visitors as to why there is new content inaccessible to them. It would look something like this:

A password protected gallery post listed publicly on a WordPress blog page

To fix it, install PPWP – Password Protect Pages. Its visibility settings keep protected posts out of your blog page, archives, search results and the Recent Posts widget, so visitors never run into an entry they cannot open. Your site will now look like this:

The same WordPress blog page with the password protected post hidden from the list

The best part is this works for any password protected content and not just Imagely galleries.

Prefer not to add a plugin? WordPress has been able to do this on its own since version 3.9. Post queries accept a has_password argument, and setting it to false returns only the posts that are not protected. Added to your theme’s functions.php, this clears them from your blog page and archives:

add_action( 'pre_get_posts', function( $query ) {
    if ( is_admin() ) {
        return;
    }
    if ( $query->is_main_query() ) {
        $query->set( 'has_password', false );
    }
} );

Widgets and custom loops run their own queries, so those still need the plugin above or a filter of their own.

It’s worth noting that if you want granular control over indexing your pages and posts as well, AIOSEO lets you stop a page or post from being indexed by search engines. If you would rather not bother with that, no need to worry: search engines cannot crawl a page or post that is password protected anyway.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how NextGEN Gallery is funded, why it matters, and how you can support us.

author avatar
Chris Christoff

Experience the Imagely Difference

Best WordPress Theme & Plugin For Photographers

Enter the URL of your WordPress website to install

Upgrade to Imagely Pro

Imagely is perfect for photographers, designers, bloggers, and creative professionals who want more than just a gallery.

Built in eCommerce and print fulfillment

90+ themes and designs

Tons of customizations and options

14 day money back guarantee

Popular on Imagely Right Now!

How to Add a Lightbox to WordPress (Free and Pro Options) tutorial card from Imagely, with a glowing neon frame around leaves

How to Add a Lightbox to WordPress (Free and Pro Options)

A visitor taps one of your gallery thumbnails. What opens next decides whether they keep…
Ultimate List: Best WordPress Plugins for Photographers

25 of the Best WordPress Plugins for Photographers (2026 Guide)

WordPress is one of the most popular platforms for photographers looking to create a stunning,…

Add A Comment