“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).

Comments

  1. User Avatar
    TeMc
    Permalink to comment#

    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. User Avatar
    Rafie
    Permalink to comment#

    Glad you found it useful! :)

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

  3. User Avatar
    Hazel Dio Febriadi
    Permalink to comment#

    wow, great, thanks friend

  4. User Avatar
    Tom
    Permalink to comment#

    Thanks for sharing all this good stuff!

  5. User Avatar
    webmaestro
    Permalink to comment#

    Thanks

  6. User Avatar
    Rajesh Namase
    Permalink to comment#

    Good tips, but new WordPress version provides this feature by default.

  7. User Avatar
    YandexBot
    Permalink to comment#

    Note. If you are using in your WordPress template for localization files (*. mo, *. for).
    And since you can just:

  8. User Avatar
    arbtech
    Permalink to comment#

    I’ve noticed the new WP provides this anyway. Anyone else?

  9. User Avatar
    Sam Logan
    Permalink to comment#

    Thanks for the awesome little snipper. @arbtech some themes provide it but many don’t!

  10. User Avatar
    krishna
    Permalink to comment#

    Glad you found it useful! :)

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

  11. User Avatar
    Jens
    Permalink to comment#

    short code -> big solution…. thanks

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

Submit a Comment

icon-closeicon-emailicon-linkicon-menuicon-searchicon-tag