0

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

  • 1
    You have a edit link in the admin bar, if the user have this admin bar active in the user settings and is logged in. Maybe this is enough. – bueltge Sep 23 '16 at 10:33
  • @bueltge you're right sorry I wasn't precise enough so I updated my question. – user310291 Sep 23 '16 at 11:25
2

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.