Code: Adding Edit Buttons to WordPress
June 20th, 2009
Code Snippets, WordPress Tutorials
There are a growing number of premium themes on the market these days for WordPress users, many of which are extremely advanced, yet I’ve found that many designers fail to add some of the most basic things all themes should have. One of the things many designers forget to do is code ”edit” buttons on their posts, pages, and comments.
For those unfamilar with these buttons, they only show up for people who are logged into the admin panel (readers can’t see them). When clicked, you are routed directly to the post/page or comment within the admin panel so you can edit the post. It has been my experience that having access to these buttons can save a lot of time when trying to manage and update older posts.
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**"), ''); ?>
Don’t forget that you can also wrap them in a div to control its placement and appearance.

