How to add an “edit” link to all of your WordPress Posts

By | March 19, 2009

Sometimes you look at a post that you or a fellow author has published, and you see a little typo. Well, while you could go from there, to the admin dashboard, and then to the edit page, and then find the page, well, that’s just not much fun now is it? Well, here is a simple little design hack that you can use to have an edit link be posted on every post made on your blog so you can do those quick-edits anytime you need to.

if (current_user_can('level_10')){ ?>
    <a href="<?php bloginfo('wpurl');?>/wp-admin/edit.php?p=<?php the_ID(); ?>">Edit Post</a>
<?php } ?>


The current_user_can() function checks the level of the current user if you are logged in, and if you have sufficent permissions, then you can edit the post. I’m going to assume that you don’t want anybody that’s below an administrator to edit a post, so we are going to use current_user_can(’level_10′) to make sure that only administrators can edit said post.

You can change that to whatever you want, and what permissions the user must have to edit a post.

Category: Uncategorized