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.
Gain access to all tutorials
- Premium tutorials covering WordPress, Laravel and VueJS
- Download premium content
- Download premium WordPress plugins
- Only $5 a month
Join the weekly newsletter
Sign up for our newsletter. You'll be updated on new tutorials as they come available.
Subscribe today and get a 50% discount code to Paulund