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. 

Kyle Eslick is WordPress enthusiast who took his passion for WordPress to the next level in 2007 by launching WPHacks.com as a place to share hacks, tutorials, etc. Follow Kyle on Twitter @KyleEslick!

  1. Monika @ The Writers Manifesto says:

    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

  2. Allen says:

    Hi, I copied the edit_post_link from the article but it does not appear in my template.

  3. Kyle Eslick says:

    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.

  4. Dawn says:

    I needed this. Found you on front page of google with search add edit posts wordpress. Good job!

  5. Rashed says:

    Thanks a lot. 🙂

  6. Extremely useful tutorial! I needed exactly this snippet of code. Thanks!

  7. Gary Crossey says:

    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.

  8. enlightenedhorsemanship says:

    This is awesome! Thanks so much. Simple, easy fix to a real problem for me.

  9. Jeff Williams says:

    Thank you so much for this hack, it really saved me!

  10. Benjamin says:

    Thanks a lot friend! Your post really helped a lot!

  11. Jeremy BOYE says:

    Very usefull.

    I’ve just tested it on a blog and it work well.

    Many thanx for this infos.

  12. Tim P says:

    May 2012, and still a useful post. That’s good value!

Trackbacks/Pingbacks »

  1. Group Writing Project - The Entries | TheWritersManifestoBlog says:
  2. Who Needs Tutorials? Do I Hear Everybody? says:
  3. Who can’t use a couple of tutorials? says:
  4. My top picks for the WritersManifesto’s group writing project says:
  5. My top picks for the WritersManifesto’s group writing project says:
  6. Blogging Tutorial Group Writing Project - My Online World says:
  7. Edit Buttons ??? WordPress Theme ?????????????????? ¦ My Gorgeous Coner of the World Wide Web says:
  8. 100+ Killer Wordpress Resources | Steffan Antonas' Blog says:
  9. Add an edit now button to wordpress | Hyperspatial Design LLC says: