How to automatically add edit link on frontpage post of any wordpress theme?

Hi I searched google for a plugin to do so, I can’t find any. Can you recommend me one if not can I create it myself though I’m beginner in wordpress dev ? If yes can you give me some clues.

Thanks.

Update: I’m not interested in having edit link in admin bar; I bought a plugin which instructs me something I don’t want to do by hand on dozens of themes :

enter image description here

Please give me an answer, I’m desperate 🙂

Solutions Collecting From Web of "How to automatically add edit link on frontpage post of any wordpress theme?"

As lot of themes use the_content() to display the post content. you can use the_content filter hook to add the edit link before/after the content.

Since you want this work outside themes, you have to put the following code in a file, and store it in your plugins folder then activate it as a plugin.

<?php
/**
 * Plugin Name: Add Edit Link in Frontend
 * Description: Append post edit link to content
 * Version: 1.0.0
 */

function wpael_content_edit_link( $content ) {

    $content .= '<br /><div style="font-size: 14px"><a href="'.  get_edit_post_link( get_the_ID() ) . '">Edit</a></div>';
    return $content;
}
add_filter( 'the_content', 'wpael_content_edit_link', 10 );