现在的位置: 首页wordpress>正文
如何在wordpress文章中插入广告(无插件)
发表于6年前 wordpress 评论数 3 ⁄ 被围观 8,105 views+

Warning: Use of undefined constant smart_ads_days - assumed 'smart_ads_days' (this will throw an Error in a future version of PHP) in /www/wwwroot/welovelead.net/wp-content/plugins/smart-ads/smartads.php on line 341

WordPress是我们首选的建站利器,有时候我们想在每篇文章的头部/尾部/环绕插入广告,虽然可以利用一些插件做到,但本人测试了几个插件,效果都不太理想。而且本着为我们网站减负的宗旨,最好还是少用一些插件。无插件实现文章中插入广告的方法如下:

1. 在Wordpress文章内容顶部加广告:

在wp后台点击外观—编辑,在右侧的列表中找到single.php,ctrl+f查找<?php the_content()代码所在的地方。(有时候<?php the_content(); ?>的括号中间会有别的内容,所以不要直接查找<?php the_content(); ?>,而是查找<?php the_content())

在<?php the_content()上面加上广告代码即可,示例:

<div style=”padding:0px 10px”>

广告代码

</div>

<?php the_content()

2.在Wordpress文章内容底部插入广告

类似于在文章顶部插入广告,这回广告代码要加在<?php the_content()下面,示例:

<?php the_content()

<div style=”padding:0px 10px”>

广告代码

</div>

3.实现Wordpress文章环绕广告(左侧或右侧)

类似于在文章顶部插入广告,实现的关键是用float控制图片或者文字广告浮动位置,示例:

<div style=”float:left(right); padding:0px 10px″>

广告代码

</div>

<?php the_content()

本博是把welovelead公众号的二维码作为广告放到了每篇文章的底部,在这篇文章里你应该已经看到了效果。



如何在wordpress文章中插入广告(无插件):目前有3 条留言

  1. 画景面膜 : 2020年04月18日13:05 回复

    没安装成功,我在本地在试试看

  2. 学美文网 : 2019年04月16日07:53 回复

    看完了,赶紧试一试,找了好久才有这么全的

  3. 跨境电商之家 : 2018年03月26日20:47 回复

    非常不错,用上了,谢谢。

给我留言


/ 快捷键:Ctrl+Enter
不想听你唠叨×