1 ???一、修改文章頁(yè)面模板single.php
如何在WordPress中每篇文章的末尾添加原文鏈接?
使用WordPress建站的朋友,若想要添加“原創(chuàng)文章若轉(zhuǎn)載,請(qǐng)注明本文鏈接:”,實(shí)際上非常簡(jiǎn)單。
這里就分享2種在WordPress文末添加本文鏈接URL的方法。
在WordPress主題模板文件中,打開single.php,搜索以下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>
建議這種方法,不僅可以添加到博客日志頁(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'); ?>
希望我們網(wǎng)站( http://news.qtyiliao.cn/ ) 分享的《WordPress文章末端如何添加本文URL?WP原文鏈接PHP代碼》,對(duì)您有幫助。