I know how to check capabilities for logged in users, with

$can_read = current_user_can('read',$post->ID);

But the above code returnes false when the user is not logged. So how can I check if the visitor has access to it?



1 Answer 1


Vistors usually always have the rights to access a post. Only exceptions that I know are drafts, password protected posts or post_types that are not public accessable.

You could use get_post_status() and post_password_required()

  • ...or should I run a WP_Query instead of my current get_post() ?
    – gordie
    Feb 22, 2022 at 20:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.