Beginner's Guide for WordPress / Start your WordPress Blog in minutes

How to Add an Edit Post Link to WordPress Posts and Pages

Do you want to add an edit post link to your WordPress posts and pages?

An edit post link lets you easily go to the post edit screen from the front end of your site to make quick changes.

In this article, we’ll show you how you can add an edit post link to your WordPress pages and posts.

How to add an edit post link to WordPress posts and pages

Why Add an Edit Post Link to WordPress Posts and Pages?

Adding an edit post link to WordPress posts and pages lets you make quick and easy changes to your content.

Instead of searching through your posts and pages in your WordPress dashboard, you can simply click the edit post link on the front end of your website. This will open up the post or page editor screen directly.

example edit post link on front-end of WordPress blog post

Note: The edit post link will only be visible to users who are logged in and have the proper user role and permissions.

A lot of WordPress themes have this feature, but sometimes it’s removed by developers.

If your theme doesn’t have this feature, then you’ll want to add it manually.

That being said, let’s show you how to add an edit post link to WordPress posts and pages.

How to Add an Edit Post Link to WordPress Posts and Pages

To add an edit post link to WordPress, you’ll need to add code to your WordPress files.

We’ll show you 2 different methods to add the code to your site:

The first method is super easy and you don’t need to have any coding experience. But, it doesn’t work with all themes and you won’t have control over exactly where the link appears.

The second method is more technical, and you’ll need to have some knowledge of PHP so you know where to place the code. However, it will give you control over exactly where the edit link appears.

That said, let’s go over these methods.

Method 1: Add an Edit Post Link in WordPress using WPCode (Recommended)

For this method, you’ll have to add a code snippet by editing your theme’s functions.php file or using a code snippets plugin. You can see our guide on how to paste snippets from the web into WordPress for more detailed instructions.

We’ll be using the WPCode plugin because it’s free, easy to use, and won’t break your website if anything goes wrong.

To get started, you’ll need to install and activate the WPCode plugin. You can see our guide on how to install a WordPress plugin for step-by-step instructions.

Once the plugin is activated, a new menu item labeled ‘Code Snippets’ will be added to your WordPress admin bar. When you click on it, it will show you a list of all the custom code snippets you have saved on your site. Since you just installed the plugin, your list will be empty.

Go ahead and click on the ‘Add New’ button to add your code snippet.

Click the Add New Button to Add Your First Custom Code Snippet in WPCode

This will bring you to the Add Snippet page. From here, you can choose a code snippet from the built-in library or add your own custom code.

For this tutorial, navigate to the ‘Add Your Custom Code (New Snippet)’ option and click on the ‘Use snippet’ button underneath it.

Add your new custom code snippet in WPCode

Next, you’ll need to name your snippet (we called ours ‘Add edit link to single posts’) and then copy and paste the following code in the ‘Code Preview’ box:

add_action('loop_start', function () {
    if (!is_singular() || is_page() || !is_main_query()) {
}, 99);

Don’t forget to choose ‘PHP Snippet’ as the code type from the dropdown menu on the right side of the screen.

Paste code snippet in WPCode to add edit post link

Then, simply toggle the switch from ‘Inactive’ to ‘Active’ and click the ‘Save Snippet’ button at the top of the page.

Activate and save your custom code snippet

Now when you view a blog post, you should see an ‘Edit’ link at the top.

edit link added to single post

We’re using the Astra theme on our test site, and here’s where our edit link appears. It may look different on your site depending on your WordPress theme.

Method 2: Add an Edit Post Link by Manually Editing Your Theme Files

You can modify the individual theme files directly or create a child theme to override these theme files.

We recommend creating a child theme, so you don’t lose the changes you’ve made when you update your theme. For more details, see our beginner’s guide on how to create a WordPress child theme.

Whether you’re editing theme files directly, or creating a child theme, you need to copy and paste the following code and add it to your theme’s single.php, post.php, index.php, or other content template file.

<?php edit_post_link(__('{Edit}')); ?>

This code simply adds a post edit link to your WordPress posts and pages. You can change the ‘{Edit}’ text to whatever you want the link to say.

For most themes, you’ll want to add this code inside the post loop directly after the post meta data.

For example, here’s how the code would look at the end of a theme’s post meta data.

By <?php the_author_posts_link(); ?> on <?php the_time('F jS, Y'); ?>  in <?php the_category(', '); ?> <?php edit_post_link(__('{Edit}'), ''); ?>

You can also add this code to any part of your theme you want the post edit link to display. For example, you can add it to the bottom of your post content.

Once you’ve added the code and saved the file, you need to upload it to your theme directory in your WordPress hosting account.

To do this, you can use an FTP client, or the file manager option in your WordPress hosting control panel.

If you haven’t used FTP before, then you might want to check out our guide on how to use FTP to upload files to WordPress.

Now, when you’re logged into WordPress and are viewing a post or page on the front end, you can simply click the ‘Edit’ link, and you’ll be taken to the post editor screen.

Post edit link WordPress post example

We hope this article helped you learn how to add a quick edit button to WordPress posts and comments. You may also want to see our guide on how to get a free SSL certificate for your website and our expert picks of the best email marketing software for small businesses.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

10 CommentsLeave a Reply

  1. Thanks, it works in posts but not in pages. My theme is Blocksy. How to enable it on pages?

  2. Thanks, really helped saving time. After used a new theme on one of my site, i missed this feature which exist other site’s themes, i quickly added.

  3. The idea of adding the Quick Edit to posts is great, but can I also add it to Links. I have a large number of links that need to be re categorised and Quick edit would be a great help.

  4. I know this is an old post, but I really needed to thank you for this. You instructions were simple to follow (and understand) and solved my problem perfectly! =)

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.