edit_post_link:
顯示發(fā)布的編輯帖子鏈接。
https://developer.wordpress.org/reference/functions/edit_post_link/
get_edit_post_link:
檢索發(fā)布的編輯帖子鏈接。
https://developer.wordpress.org/reference/functions/get_edit_post_link/
添加于博文循環(huán)函數(shù)內(nèi)
把它放在你輸出the_content()附近的主題文件中(可能在single.php或page.php文件中),以創(chuàng)建一個(gè)鏈接,你可以點(diǎn)擊它進(jìn)入管理員進(jìn)行編輯。此鏈接僅在查看者登錄并且具有編輯該頁(yè)面(管理員或作者)的適當(dāng)權(quán)限時(shí)才可見(jiàn)。
<?php edit_post_link(__('Edit This')); ?>
?有編輯權(quán)限的人(超級(jí)管理員,管理員,編輯,作者),顯示編輯按鈕:(推薦,來(lái)源于官方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編輯文章鏈接標(biāo)簽:edit_post_link
來(lái)源于:
https://www.beizigen.com/1687.html
WordPress模板標(biāo)簽edit_post_link用于輸出編輯文章的鏈接,必須用在The Loop主循環(huán)中。
edit_post_link( string $text = null, string $before = '', string $after = '', integer $id = 0, string $class = 'post-edit-link' )
函數(shù)參數(shù)
$text
字符串值,默認(rèn)為空
鏈接的錨文本
$before
字符串值,默認(rèn)為空
在鏈接前輸出的文本
$after
字符串值,默認(rèn)為空
在鏈接后輸出的文本
$id
整數(shù)型,默認(rèn)值:0
指定文章ID,輸出該文章的編輯鏈接。
$class
字符串值,默認(rèn)值:post-edit-link
鏈接的類名
edit_post_link()函數(shù)使用示例
', ''); ?>
擴(kuò)展閱讀
edit_post_link()函數(shù)位于:wp-includes/link-template.php
相關(guān)函數(shù):
參考:
About:
if( current_user_can('administrator') ) {
echo '?????編輯';}