edit_post_link:
顯示發布的編輯帖子鏈接。
https://developer.wordpress.org/reference/functions/edit_post_link/
get_edit_post_link:
檢索發布的編輯帖子鏈接。
https://developer.wordpress.org/reference/functions/get_edit_post_link/
添加于博文循環函數內
把它放在你輸出the_content()附近的主題文件中(可能在single.php或page.php文件中),以創建一個鏈接,你可以點擊它進入管理員進行編輯。此鏈接僅在查看者登錄并且具有編輯該頁面(管理員或作者)的適當權限時才可見。
<?php edit_post_link(__('Edit This')); ?>
?有編輯權限的人(超級管理員,管理員,編輯,作者),顯示編輯按鈕:(推薦,來源于官方2019主題)
wp-content\themes\twentynineteen\template-parts\content\content-page.php
第34行
<?php if ( get_edit_post_link() ) : ?>
<footer class="entry-footer">
<?php
edit_post_link(
sprintf(
wp_kses(
/* translators: %s: Name of current post. Only visible to screen readers */
__( 'Edit <span class="screen-reader-text">%s</span>', 'twentynineteen' ),
array(
'span' => array(
'class' => array(),
),
)
),
get_the_title()
),
'<span class="edit-link">',
'</span>'
);
?>
</footer><!-- .entry-footer -->
<?php endif; ?>
?WordPress編輯文章鏈接標簽:edit_post_link
來源于:
https://www.beizigen.com/1687.html
WordPress模板標簽edit_post_link用于輸出編輯文章的鏈接,必須用在The Loop主循環中。
edit_post_link( string $text = null, string $before = '', string $after = '', integer $id = 0, string $class = 'post-edit-link' )
函數參數
$text
字符串值,默認為空
鏈接的錨文本
$before
字符串值,默認為空
在鏈接前輸出的文本
$after
字符串值,默認為空
在鏈接后輸出的文本
$id
整數型,默認值:0
指定文章ID,輸出該文章的編輯鏈接。
$class
字符串值,默認值:post-edit-link
鏈接的類名
edit_post_link()函數使用示例
', ''); ?>
擴展閱讀
edit_post_link()函數位于:wp-includes/link-template.php
相關函數:
參考:
About:
if( current_user_can('administrator') ) {
echo '?????編輯';}