Can I use a php counter in a tumblr theme?
I would like to use the counter to add a class to every 4th post, example:
<div class="<?php if($i % 4 == 0) {echo 'noCol';} ?>">
{post}
</div>
is this possible or is there a jQuery option? I know I could achieve the same thing using css but this is not cross browser friendly!
No, you can't run PHP in Tumblr themes. But you can easily do it with JavaScript:
$('.post').filter(function(i){ return i % 4 === 0; }).addClass('noCol');
Using Theme Operators:
class="{block:Post4}noCol{/block:Post4}{block:Post8}noCol{/block:Post8}{block:Post12}noCol{/block:Post12}"
Using CSS:
.post:nth-child(4n) { /* styles for noCol here */ }
the only browser that doesn't support nth-child
is IE8 http://caniuse.com/#search=nth-child
This is solvable with out jQuery or javascript.