I talked previously about how there are a lot of basic things WordPress theme authors can do to make a theme more functional and appealing to WordPress users, such as separating blog comments from trackbacks. Another thing that theme authors often forget to do is add “edit” buttons to posts, pages, and comments. Having access to these buttons can save blog authors a lot of time when trying to manage their blogs. As a result, I decided to write up a quick tutorial that explains the really simple process of adding edit buttons to your WordPress theme.
If you’d like to add an “Edit” button on your individual posts or pages, here is the code you will want to place somewhere in your post and/or page template (usually called single.php and page.php) where you want it to display:
<?php edit_post_link(__("**Edit**"), ''); ?>
If you’d like to add an “Edit” button to your individual comments, here is the code you need to place somewhere in your comments loop (usually called comments.php) where you want it to display:
<?php edit_comment_link(__("**Edit**"), ''); ?>
A couple of quick notes about adding edit buttons to your theme:
- These edit links will only appear if you are logged in with the appropriate priviledges (administrator, editor, etc.). Your traffic will not see them.
- You can wrap them in a div or whatever you would like to and then set its position in your stylesheet to appear where you want it to.
















Hi Kyle,
Excellent idea your blog. I shall be back for more great stuff from you. Thanks for the entry and best of luck for a chance at the top 3.
Monika
Hi, I copied the edit_post_link from the article but it does not appear in my template.
Allen,
Can you verify that you were logged in at the time? You have to be logged in as Administrator (or one of the levels with editing permissions) in order for the Edit button to show up. It won’t show up for your readers.
I needed this. Found you on front page of google with search add edit posts wordpress. Good job!
Thanks a lot.
Extremely useful tutorial! I needed exactly this snippet of code. Thanks!
Thanks for the line of code… I tried a few plug-ins before. This is a much better solution. I give you a link from my credit pages. Thanks for making life easier.
For anyone who doesn’t have this feature on their WordPress site – it makes all the difference.
This is awesome! Thanks so much. Simple, easy fix to a real problem for me.
Thank you so much for this hack, it really saved me!
Thanks a lot friend! Your post really helped a lot!