• I’m trying to set up a blog that auto formats posts based on their recency in the post-counts. So, the latest story would have ‘feature’ formatting, the next four would have ‘sub-feature’ and the next four probably just a one-line link.

    I know it’s probably possible to do this with custom keys, but I don’t really want to have to change all the metadata every time I add a new post. Is there a way to do this via the post count? I’m imagining in psuedo code:

    If (this post_num = latest post){
    
    style it as a feature
    
    }else if(this post_num > post_count - 4 & < latest post){
    
    style it as a sub-feature
    
    }else if ((this post_num > post_count - 8 & < post_count - 4){
    
    style it as one liner
    
    }else{
    
    dump it in the archives/don't display on front page
    
    }

    I’ve had a good search around and can only find the custom keys method, but it seems to me this should be possible to automate. Or is this a really clunky way of doing it?

    (Added info: I can hack around in PHP, especially given some example code, but I’m not that competent in it.)

Viewing 3 replies - 1 through 3 (of 3 total)
  • This thread might point you in the right direction.

    (I’m looking for an ‘if post is fourth, eight, twelfth.. andsoforth solution, found an article about changing the >=4 in <?php if($post_count >= 4) : ?> to something like 1+n, but can’t find it anymore. If anyone has a suggestion.. : )

    In relation to the between brackets in my previous reply:

    <?php if($post_count == n+5) : ?>

    would allow doing something with every nth (in this case 4th) post, e.g. setting some css selector.

    Thread Starter apolaine

    (@apolaine)

    Thanks (and sorry for my delayed thanks), that looks like the ticket. Or at least close enough to it. An if, else in the while loop makes perfect sense.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Count related formatting?’ is closed to new replies.