× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Logged Out Users & Private Posts

Trevor Elwell
Oct 28, 2015
<p>During this session we ran across a WordPress error which was giving us some problems. Essentially, our custom theme was using WP_Query(); to pull both 'Publish' and 'Private' posts. Unfortunately, though these posts were being used to populate the archive page, clicking on one of the links would yield a 404 error since a non-logged-in user would not have the proper permissions to view a 'Private' post.</p> <p>As an aside, the clients were using the concept of 'Private' posts improperly, it seems, which lead to this problem to begin with. </p> <p>Anyway, after some debugging we were able to restructure the query to only include 'Publish' posts which all users could view properly. </p> <p><strong>TL;DR</strong>: If you're experiencing a bug where something happens with a logged in user and not with a logged out user on WordPress it might have to do with Private posts. If not, check to see if other authentication functions like is_user_logged_in() and see if they are the guilty party. </p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus