Display if user logged in is post author

I want to add post edit link to posts on archive page and want to show those links to post author only if he is logged in. Tried finding in documentation but couldnt find it.

This is a pretty unique use case so it makes sense that it wouldn’t be something that’s covered in the docs, but it is an interesting idea! Looking into it, it seems that WordPress uses the following URL structure when editing as post:


Where 12345 is the post ID. So if the current user is the author of the post, you could just use an <a> tag and make it fill in the current post ID dynamically. Something like this:

<If user_field=name is value="{Field author_name}">
    Hey there, <Field author_full_name />! 
    <a href="{Url site}/wp-admin/post.php?post={Field id}&action=edit">
      <button>Click here to edit your post.</button>

You’d probably want to replace Url site with your actual site URL since if you’re just using it on your own site it probably doesn’t make sense for that to be dynamic. But the code as I wrote it should be copy-pastable on any site and it should work. Hope that’s helpful!

Actually, looking into this a bit more, I just realized that there’s an edit_url field that’s available on post loops. So that makes this even easier. In its most distilled form, you’re looking at syntax like this:

<If user_field=name is value="{Field author_name}">
  <a href="{Field edit_url}">Edit post</a>
1 Like

Thanks @benjamin it works

1 Like