Display ‘edit’ link in a custom WordPress listing

Use this snippet inside your custom WordPress posts / pages listing function.

<?php
if (current_user_can('edit_posts')) {
    $output = '<a href="' . get_edit_post_link($post->ID) . '">Edit this post</a>';
}
echo $output;
?>

Marko Dugonjić is a designer specialized in user experience design, web typography and web standards. He runs a nanoscale user interface studio Creative Nights and organizes FFWD.PRO, a micro-conference and workshops for web professionals.

Interested in more content like this?