每3个帖子后展示一次广告 [英] Display Ad every after 3 Posts

查看:77
本文介绍了每3个帖子后展示一次广告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在wordpress博客中每隔3个帖子显示一次广告。你们可以检查代码中有什么问题吗?

I'm trying to display an advertisement every after 3 posts in a wordpress blog. Could you guys check something that's wrong in the code?

请参见代码

推荐答案

我不知道为什么在那使用模数。
http://php.net/manual/zh/language.operators .arithmetic.php

I can't figure out why are you using modulus there. http://php.net/manual/en/language.operators.arithmetic.php

我认为那是您不想要的东西。
我通常这样做的方式是:

I think that is something you didn't want. The way I usualy do this is:

if( $ad_counter >= 3 ) {
$ad_counter = 0;
echo '<h2 style="color:red;">Advertisement or custom content here</h2>';
}

您可以删除第12行:)

And you can remove line 12 :)

这篇关于每3个帖子后展示一次广告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆