The MU forums have moved to WordPress.org

Every X# of posts do something? (5 posts)

  1. ergate
    Member
    Posted 17 years ago #

    Hey, I posted this over at the regular wp support forum because I am messing about with a theme (no response yet), but since I will be using this on a mu site maybe I can get a little help over here. (and we are so much smarter over here ;)

    How can I do this. I am looking through the forum(s) and the codex, and I cannot come up with a solution.
    I have found this
    http://www.tamba2.org.uk/wordpress/adsense/
    and it does some of what I am looking for. Is there a function built in to WP or a implementation of the above link that will do something every certain number of posts?
    For example:
    post 1
    post 2
    post 3
    DO SOMETHING
    post 4
    post 5
    post 6
    DO SOMETHING
    post 7
    post 8
    post 9
    DO SOMETHING
    ...and so on and so on no matter how many posts are on the page.

    I am thinking of modifying the previously mentioned script, I figure it would be with this portion

    <?php
    $postnum = 1;
    $showadsense1 = 1;
    ?>

    that would indicate that the something would be after post num 1, I can get it to place after post three, but not to happen after every third post.

  2. agidi
    Member
    Posted 17 years ago #

    Now that would be REALLY usefull!

    excellent idea.

    I have no programing skills, but will gladly help to test.

    keep on the good work

  3. lunabyte
    Member
    Posted 17 years ago #

    if have posts:
    $y = array( 3, 6, 9, 12, 15);
     $x = 1;
    

    before the endwhile:

    $x++;

    During the loop:

     if ( in_array($x, $y) ) {
         do whatever
    }
  4. ergate
    Member
    Posted 17 years ago #

    Lunabyte: That did it!!!

    Thanks

    Now I am off to style the theme and css.

    Thanks again.

  5. lunabyte
    Member
    Posted 17 years ago #

    Basic php, really.

    That's the nice thing about the way WP sets up its templates.

    Users can use simple tags, granted their php but what's the difference really between {&my_tag_name} and

    <?php my_tag_name(); ?>
    at the end of the day? Nothing, really.

    But with the templates as they are, you can do pretty much anything your knowledge allows inside a template. I know people have suggested moving to SMARTY or whatever (yuck in my book), but it just doesn't make sense. A tag is a tag, is a tag. The end user still has to insert it.

    The difference comes in what advanced users can do with it, and there really isn't anything you can't do with the current templates and a strong knowledge of php. Simple when it needs to be, but has unlimited potential. A definite win win situation.

About this Topic