开发者

Display Ad every after 3 Posts

I'm trying to display an advertisement every after 3 posts in a wordpress blog. Could you guys check something t开发者_Python百科hat's wrong in the code?

See the code here


see Make $after_every = 0 and add $after_every++ bottom of while loop

then add one condition

if($after_every%3==0){ Show add}

I think it works.


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>';
}

And you can remove line 12 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜