Warning: mysqli_query(): (HY000/1030): Got error 28 from storage engine in /home/wpthemes/public_html/wp-includes/wp-db.php on line 1877
How to add an “edit” link to all of your WordPress Posts | WPThemes.com - WordPress Themes
Warning: mysqli_query(): (HY000/1030): Got error 28 from storage engine in /home/wpthemes/public_html/wp-includes/wp-db.php on line 1877

March 19, 2009

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

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.

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

editlink1

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.


Previous Post and Next Post


Try HostGator Webhosting for 1 cent for the 1st Month Click here and enter "wordpress"

Leave a reply

* means field is required.

*

*