[WordPress] Show edit link in post
There are a lot of wordpress theme does not display the edit link (edit button) in the article. To display the edit link in wordpress I use the function:
<?php edit_post_link( $link, $before, $after, $id ); ?>
In that:
$link: Edit text containing links that we want to show
$before: Edit link text ago (The default is no)
$after: Đoạn text sau edit link (The default is no)
$id: id article needs repair (default without)
Add a necessary thing is that we need check whether the user can edit not, if so, to show new edit the following link:
if ( current_user_can('edit_post', get_the_ID())
So complete code to display the edit link in wordpress:
<?php if ( current_user_can('edit_post', get_the_ID()) ) { edit_post_link('edit', '', ''); } ?>
Recent Comments