Help visitors easily identify your premium content and prompt them to upgrade when browsing your posts.

This code recipe uses CSS to overlay a message on the featured images for a members-only post. If the user does not have membership to view that content, the message is shown on top of the featured image in your WordPress site like the sample screenshot below.

Add Locked Post Message Image Overlay Code Recipe

CSS recipes are especially tricky to make compatible for every WordPress site and theme. This recipe requires that your theme includes featured images and loads them using a WordPress hook that includes the post_thumbnail_html filter.

Your theme may already be using this filter to do something to images, or your theme may have other native CSS that conflicts with this code. Please open a ticket in the support area for basic help adjusting the recipe PHP or CSS included below.

Example screenshot of a blog grid using the overlay on locked posts

The Code Recipe (PHP)

This technique requires both a custom PHP function and a block of customization CSS. First, here is the custom PHP required for the overlay:

Adding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.

The Custom Styles (CSS)

Adding the Custom CSS to Your Website

This custom CSS can be placed in a stylesheet for PMPro Customizations or pasted directly into the Appearance > Customize > Additional CSS field. You can also include this CSS in your child theme’s style.css file. Do not place custom CSS in any file in a theme that gets regularly updated or you will lose your code.

Note: This recipe will blur the featured image, but it does not protect the original image source. Users without a membership can still view the source code and see the image.

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Featured Image for Membership Site Development Course: The Basics
Was this article helpful?
YesNo