Does your WordPress theme include a quick edit button or link for editing your WordPress posts and comments?
Quick edit links help you easily edit your WordPress posts from the front-end of your WordPress blog. It’s much easier rather than going back to your Posts in the admin section and searching for the particular post to edit it.
The quick edit links can be really time-saving and efficient for WordPress admins.
If your website’s theme doesn’t have the quick edit button built-in, you might consider adding it.
In this post, let’s go through the steps of adding the button to your theme.
Note: This tip is only for those who are comfortable editing their WordPress code manually.
Quick Edit Buttons for WordPress Posts
1. From the WordPress dashboard of your blog, navigate to theme editor.
Appearance >> Editor
2. Now open your theme’s single.php file and add the below code anywhere in the loop.
https://gist.github.com/pradeepdotco/99a764bbd54b561dc552
The code will display a quick edit link and can be used for pages, posts, attachments, and revisions.
The edit_post_link function used in the code above takes a maximum of 4 parameters.
https://gist.github.com/pradeepdotco/3b4bd24774361809d5cfe0784ae6e927
If you’re a developer, you can use these additional parameters within the code including;
$link : (string) (optional) The link text. Default: __(‘Edit This’)
$before : (string) (optional) Text to put before the link text. Default: None
$after : (string) (optional) Text to put after the link text. Default: None
$id : (integer) (optional) Post ID (added in WordPress 2.8). Default: None
$class : (string) (optional) CSS class name for the link (added in WordPress 4.4).
Default: post-edit-link
Quick Edit Buttons for WordPress Comments
First, check to see if you already have this option in your theme as most of the themes come with prebuilt function. If not then follow these steps.
- Open your theme’s comments.php file and add the below code.
<?php edit_comment_link(__('{Quick Edit}'), ''); ?>
https://gist.github.com/pradeepdotco/5217d16fb71bffc6c9e5
Quick Edit Link for Genesis Themes
If you use Genesis themes, there’s an easier way to include the quick edit link.
- Download and install the Genesis Simple Edits plugin.
- From your dashboard, go to Genesis > Simple Edits
- Add the post_edit
[post_edit]
shortcode to Entry Meta (above content) or Entry Meta (below content) depending on where you want the quick edit link to appear.
Using Edit Post in Navigation Menus
Alternatively, you can use the Edit Post link included in the navigation menu of your WordPress site.
When you are logged in and provided that your theme supports it (most themes have support for the Navigation Menus), you should see a Navigation menu with an Edit Post link that you can use to directly edit the post /page.
See the screenshot below showing “Edit Post” link in the Navigation Menu.
Do you use quick edit buttons in your WordPress theme?
Thanks for this code bro. It helped me
Very useful trick. Thanks Pradeep!
How can I use this with post types?