im not great in develop php, so please help me. i got a code, that displays adsense ads if the blog post count is 1. i want it to show adsense ads on first 2 posts (1 and 2) ive tried changed 1 to 1,2 but that doesnt work. heres the code to modify: <?php if ($count == 1) : ?><script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <?php endif; $count++; ?> please help me, i really need it.
Don't use the deprecated if: endif, use if { }, like so: <?php if ($count++ <= 2) : ?> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <?php } ?> Code (markup): I also took out the other redundant <script> tag.
umm, just do it if count is less than 3? <?php if ($count < 3){ ?> <script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <?php } ?>
i used the jaked method. i was planning to use ecentrinick method, but that method show the ads in the 3 first post. i didnt try krt method. thanks everyone!!
Does it make a difference? Anyway, I prefer <= 2 as it seems more logical. You are putting ads on the first 2 posts, not putting the ads before the 3rd post. Also, your code is not incrementing $count.