Add An Edit Link On WordPress Posts
On my WordPress themes I always link to have an edit link at the top of the posts by the title so that if I spot a mistake with the post I can easily edit it quickly.
Here is a WordPress snippet to use which will add an Edit this link at the top of your page. It will only be visible to the admin user and will take them directly to the edit post page.
This uses the WordPress function edit_post_link(), it must be used inside the_loop.
Just place the following in your theme where you want the edit link to appear.
<?php edit_post_link(__('Edit This')); ?>
This function takes a maximum of 4 parameters.
<?php edit_post_link( $link, $before, $after, $id ); ?>
- Link - The link text. Default is set to Edit This.
- Before - The text which is added before the link text.
- After - The text added after the link text.
- Id - The Post id to link to.
- Access 100s of premium tutorials and downloadable content
- Members content consists of premium WordPress plugins
- CSS packages, jQuery packages, tutorial demo files and templates for 100s of web development tutorials
- In-depth development tutorials
- Priority tutorial requests
- No ads
- First month free!