国产美女裸身网站免费观看视频,最新精品国自产拍福利,影音先锋av色噜噜影院,亚洲成av人无码影片

專業(yè)WORDPRESS主題設(shè)計(jì)制作

WordPress文章末端如何添加本文URL?WP原文鏈接PHP代碼(wordpress怎么添加鏈接)

發(fā)布于: 2022-11-03

1 ???一、修改文章頁(yè)面模板single.php

  • 2 ???二、添加PHP代碼到function.php文件

 

如何在WordPress中每篇文章的末尾添加原文鏈接

 

使用WordPress建站的朋友,若想要添加“原創(chuàng)文章若轉(zhuǎn)載,請(qǐng)注明本文鏈接:”,實(shí)際上非常簡(jiǎn)單。

這里就分享2種在WordPress文末添加本文鏈接URL的方法。

???一、修改文章頁(yè)面模板single.php

在WordPress主題模板文件中,打開single.php,搜索以下PHP代碼:

WordPress文章末端如何添加本文URL?WP原文鏈接PHP代碼
<?php the_content(); ?>

這行PHP代碼的下面,添加以下PHP代碼 ▼

<p>原創(chuàng)文章如轉(zhuǎn)載,請(qǐng)注明本文鏈接: <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_permalink(); ?></a></p>
  • 然后,保存更新,這樣就可以了。

???二、添加PHP代碼到function.php文件

建議這種方法,不僅可以添加到博客日志頁(yè)面的鏈接,包括feed也是可以。

打開主題文件夾中的function.php文件,并在最后添加以下PHP代碼(復(fù)制和粘貼時(shí)請(qǐng)注意中文和英文標(biāo)點(diǎn)符號(hào)):

<?php
function feed_copyright($content) {
if(is_single() or is_feed() or is_page()) {
$content.= '<div>?? ???本文來自:<a title="我們網(wǎng)站" href="https://www.wordpressx.com/" target="_blank">我們網(wǎng)站</a> ? <a rel="bookmark" title="'.get_the_title().'" href="'.get_permalink().'" target="_blank">《'.get_the_title().'》</a></div>';
$content.= '<div>?? ???本文鏈接地址:<a rel="bookmark" title="'.get_the_title().'" href="'.get_permalink().'" target="_blank">'.get_permalink().'</a> ?英雄不問來路,轉(zhuǎn)載請(qǐng)注明出處,謝謝。</div>';
$content.= '<div>?? ???有話想說:<a title="給我留言" href="'.get_permalink().'#respond" target="_blank">那就趕緊去給我留言吧.</a></div>';
$content.= '<div>?? ?? 歡迎加入我們網(wǎng)站的 Telegram 頻道:<a rel="external nofollow" title="點(diǎn)此加入我們網(wǎng)站的 Telegram 頻道" href="" target="_blank">https://www.wordpressx.com/go/tgchannel</a></div>';
}
return $content;
}
add_filter ('the_content', 'feed_copyright');
?>
  • 請(qǐng)根據(jù)你的WordPress博客做修改。

希望我們網(wǎng)站( http://news.qtyiliao.cn/ ) 分享的《WordPress文章末端如何添加本文URL?WP原文鏈接PHP代碼》,對(duì)您有幫助。

TAG:
WP技術(shù)資料 wordpress模板制作、wordpress主題開發(fā)相關(guān)知識(shí)常見問題總結(jié)
MORE
服務(wù)電話:
0533-2765967

微信 13280692153