在wordpress文章末尾添加内容的简单方法


本文整理自网络,侵删。

1、修改文章页面模板single.php
打开模版文件中的single.php,在其中搜索
在这行下面加上:

代码如下:

<p>原创文章如转载,请注明本文链接: <a href=”<?php the_permalink() ?>” title=”<?php the_title(); ?>”>
<?php the_permalink(); ?></a>
</p>

就OK了,还有一种方法:

2、打开主题文件夹内的:functions.php文件,在末尾加入代码(复制粘贴时请注意中英文标点):

代码如下:

<?php
function feed_copyright($content) {
if(is_single() or is_feed() or is_page()) {
$content.= ‘<div>本文来自:<a title=”博客” href=”http://www.1000zx.cn” target=”_blank”>小谈博客</a> &raquo; <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> &raquo;英雄不问来路,转载请注明出处,谢谢。</div>’;
$content.= ‘<div>有话想说:<a title=”给我留言” href=”‘.get_permalink().’#respond” target=”_blank”>那就赶紧去给我留言吧.</a></div>’;
$content.= ‘<div>您也可以订阅本站:<a rel=”external nofollow” title=”小谈博客” href=”http://1000zx.cn/” target=”_blank”>http://www.1000zx.cn</a></div>’;
}
return $content;
}
add_filter (‘the_content’, ‘feed_copyright’);
?>

推荐此法,不止可以在博客日志页加入链接,包括feed里也可以,实现以后的效果如本文下面显示,蓝色文字部分请根据自己的博客修改。


标签:WordPress

相关阅读 >>

wordpress反复出现需要升级数据库的解决方法

nginx服务lnmp之wordpress部署流程步骤

详解wordpress中过滤链接与过滤sql语句的方法

wordpress中限制非管理员用户在文章后只能评论一次

wordpress中设置post type自定义文章类型的实例教程

wordpress中用于获取文章作者与分类信息的方法整理

wordpress取消英文标点符号自动替换中文标点符号的优雅方法

wordpress中给文章添加自定义字段及后台编辑功能区域

使用php+ajax让wordpress动态加载文章的教程

wordpress更改用户列表排序(按注册时间排序)教程

更多相关阅读请进入《wordpress》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...