• Hi!

    I’m creating a client area in wordpress and the posts will be the projects. I need to show the post only to the user I add as an author. Each will have its own project, without appearing to other users.

    I don’t want a permission message or anything like that. The idea is to completely hide the other posts that the user is not the author of.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You can use the “pre_get_posts” action to alter any or all typical posts queries. In your action callback, verify the query is_main_query() && ! is_admin(). If so, set the “author” query var value to the return value from get_current_user_id().

    This is assuming all visitors are logged in. Consider what should happen if the user is not logged in.

Viewing 1 replies (of 1 total)

The topic ‘(Frontend) How to display only current user’s posts?’ is closed to new replies.