我想在我的帖子列表中每十個帖子放一個adsense廣場(250x250)廣告。
我試圖將此代碼添加到我的index.php,職位div中:有一個廣告空間每10個帖子重複
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count == 11) : ?>
Ad code is here
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php else : ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
它正確地出現了,但職位的所有格式改變出於某種原因。
此外,此代碼僅在第十次發佈後投放廣告,並且在第二十次後不會自動重複,等等。
這實際上並不重要,我可以重複這些數字。
模運算符'如果(($計數%10)== 0)' –
有多少AdSense廣告,你可以在一個頁面上放 – 2013-10-03 20:26:45
太多'<?php'對我的口味的限制。 。 – 2013-10-03 20:31:25