It’s easy to password protect an entire page or post in WordPress. But what if you would like to show part of the content on the page?
I did look for a plugin solution for this at first. I thought it would be easy to find a plugin that gave you a shortcode to wrap around content you wanted to keep protected. I was wrong (unless you want to utilize user roles, but I didn’t want people to have to log in). I came across Content Protector, but found it really unreliable.
But there’s a pretty easy solution if you’re OK with a little code. For this solution you will need:
- A child theme (because we’re going to be editing template files)
- An understanding of the WordPress template hierarchy
- The confidence to edit some PHP code
If this all sounds a bit much for you, you may want to check out my post on Going Beyond WordPress Basics, to build your confidence.