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:

  1. Manually edit your theme files
  2. Add a code snippet

The first 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.

The second method is much easier 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.

That said, let’s go over these methods.

Method 1: Manually Edit 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

Method 2: Add a Code Snippet

For this method, you’ll have to add a code snippet to your functions.php file or using a 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 Code Snippets 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 plugin. You can see our guide on how to install a WordPress plugin for step-by-step instructions.

Next, go to Snippets » All Snippets and click on the ‘Add New’ button at the top of the page.

adding code snippets in wordpress with a plugin

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 field:

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

    edit_post_link(__('{Edit}'));
}, 99);

Then click the ‘Save Changes and Activate’ button at the bottom of the page.

code snippet to add edit link to single posts

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

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.

edit link added to single post

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.