A Web Design Community curated by Chris Coyier

Code Snippets Gallery

Code Snippets > WordPress > “Edit This” Button on Posts and Pages Submit one!

“Edit This” Button on Posts and Pages

<?php edit_post_link(__('Edit This')); ?>

Put this in the theme file somewhere near where you output the_content() (likely in the single.php or page.php file) to make a link you can click that takes you into the admin to edit it. This link will only be visible when the viewer is logged in and has appropriate permissions to edit that page (administrator or author).

4 Responses

  1. TeMc says:

    Real handy thing to have in the theme.

    I’d like to add that:
    * It should, ofcourse, be used within the loop
    * And that aside from admins and post-authors, (global) ‘editors’ also see this link. Maybe obvious, but thought I’d say it here for completion.

    – Thanks to whomever sent this in :)

  2. Rafie says:

    Glad you found it useful! :)

    A perfect place to put is just next to the content excerpt.

  3. wow, great, thanks friend

Leave a Comment

Remember:
  • Be nice.
  • Wrap multiline code in <pre> and <code> tags and escape it first (turn <'s into &lt;'s).
  • You may use regular HTML stuff like <a href="">, <em>, and <strong>
* This website may or may not contain any actual CSS or Tricks.