[wp-testers] TAGs to show something at specific

DD32 wordpress at dd32.id.au
Fri Nov 30 15:26:07 GMT 2007


Something like this is what i'd use in your template:

<?php 

if (have_posts()) :
	$postsDisplayed = 0;
	while (have_posts()) : 
		the_post(); 
		?>
		<h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
		<?php
		if( $postsDisplayed++ % 3 == 0 ){
			?> *Adsense Code here* <?php
		}
	endwhile;
endif;
?>

Its not a plugin, but its what you want.

The % is Modulus sign, Its bsaically division, but returns the remainder..
2 % 2 = 0; // 2 can be divided by 2 and leaves 0 over
3 % 2 = 1; // 3 can be divided by 2 once, Leaving 1 left over
6 % 4 = 2; // 4 goes into 6 once, leaving 2 left over

So if you check if theres 0 left over, you can tell if its a multiple of 2 or 3, or whatever you want it to be.

Its late here, so apologies for anything outragiously stupid with this post.

D

On Sat, 01 Dec 2007 02:06:31 +1100, azrin <azrin at bbs.nu> wrote:

> somewhat the code don't work as well, as the Adsense and codecs don't work
> well with the Youtube addon...
> ----- Original Message -----
> From: "Handy" <handy.solo at gmail.com>
> To: <wp-testers at lists.automattic.com>
> Sent: Friday, November 30, 2007 4:14 AM
> Subject: Re: [wp-testers] TAGs to show something at specific
>
>
>> If you asked this in the support forums (or searched there), you'd be done
>> already :-)
>> http://wordpress.org/support/
>>
>> You might check this article for some examples that are quite similar:
>> http://www.tamba2.org.uk/wordpress/adsense/
>>
>>
>> On Nov 29, 2007 10:49 AM, azrin <azrin at bbs.nu> wrote:
>>
>>> I am asked by a client to integrate You tube Adsense code in.
>>> Thing is that, they want the ad to show only after the 2nd or 3rd
>>> ..etc...
>>> post in the main page
>>>
>>> So, is there a way to do a check like if_home && while post=2nd/3rd etc
>>> ..then show {this content}
>>>
>>> I am still abit blurr...so pls don't mind me..
>>>
>>> It's something like in http://www.marlindaradzi.com but I coded it
>>> manually.
>>> any help appreciated.
>>>
>>> Dr Azrin  ( www.azrin.net )
>>> iExploreAsia Medical Group UK
>>> part of the BBS.NU Community Websites.
>>> a member of BBS.NU-Info Perkahwinan-EbayTrust Alliance
>>> Promoting Better Family Values for all
>>> _______________________________________________
>>> wp-testers mailing list
>>> wp-testers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-testers
>>>
>> _______________________________________________
>> wp-testers mailing list
>> wp-testers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-testers
>>
>
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
> 





More information about the wp-testers mailing list