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.